PDA

View Full Version : Measure time



BioCleaner
November 1st, 2008, 10:51 PM
Can someone please tell me how to measure the execution time of a simple program I create?
Is there a command in the shell? Or do I have to introduce something in the source code(I use C)?

slavik
November 1st, 2008, 11:11 PM
the simplest way is by using the time command.

BioCleaner
November 1st, 2008, 11:38 PM
Thanks! But it displays 3 times: real,user,sys. What is the time that programming contests or acm sites usually consider. I also found an option "-f %E" in the man text. Does this display the time that they take into account?

slavik
November 1st, 2008, 11:48 PM
they don't count execution time, they count the time in minutes after the beginning of the contest until the solution was submitted.

BioCleaner
November 1st, 2008, 11:55 PM
I will give you an example. For this problem I found on an acm site the maximum execution time is 2 seconds.
http://acm.timus.ru/problem.aspx?space=1&num=1007
How can I find out the time my solution for the problem has used for a certain input?

slavik
November 1st, 2008, 11:58 PM
err, I know that they usually kill your process if it's been running for more than 2 minutes, since if it has been running that long, it is probably wrong.

I wouldn't look at the 2 second time limit.

BioCleaner
November 2nd, 2008, 12:05 AM
Some problems even have 0.1 seconds time limit. I want to check at my computer if my solution exceeds the limit before I send it. I think that the "-f %E" option shows that time but I'm not sure. If I don't include that option it shows a time that I think is a little big.

slavik
November 2nd, 2008, 12:06 AM
look up the UVa judge :)

BioCleaner
November 2nd, 2008, 12:10 AM
In this case I can but in other cases like school programming contests...

CptPicard
November 2nd, 2008, 04:20 AM
Running times on different machines are not comparable anyway...

BioCleaner
November 2nd, 2008, 12:47 PM
I know that but even a bad apeoximation is better then no aproximation.