I am trying to make a Online C Compiler
So multiple user can compile their code on a central server. And I can judge their code .
I want to calculate the time complexity ~ CPU Usages and the space complexity ~ Memory Usages of the C program. I am using Windows XP
and cygwin gcc 4.5 compiler
.
As a blog I am trying to take the memory usages of a process by pview
c:\cygwin\bin\gcc-3.exe -Wall source.c -o a.exe 2>&1 | pv -o"%i\t%e\t%c2%%\t%m(K)\t%n" gcc-3.exe
It is return the memory usages by gcc-3 is 3520 KB in each cases either try to use 1000KB size or use no size i.e. simple printf statement.
Can you help me by the automate way to calculate the memory usage or space complexity of the program this is not necessary to use the above code It is only I am trying.
Suggestion and Answers are welcomed
Under Cygwin, I guess you can use getrusage. It contains many information about memory usage. This question gives more info about how it works and a practical example.
For windows only program, you have GetProcessMemoryInfo. See this question for more info about how it works.