Most online judges have some sort of system to measure execution time and memory consumption. An example is shown here. How is it done? Is there a simple UNIX utility I can use to run similar tests on my own programs?
Valgrind with all it's tools will give you some info:
cachegrind
- a cache simulatorcallgrind
- call graph tracing - allows to get the cost of calls and show what is happening in your programmassif
- info about heap memory usagememcheck
- memory leak checkingIn addition you can use more sophisticated software, like Intel VTune.
If you are interested in low level details and the real hardware counters yourself then have a look at the perfmon2 which has some chances of getting into mainstream kernel some time in the future.
And search old questions - there are many posts on this subject.