| unkn00wn (68) | |||||
|
Hello, i used two methods to compute time elapsed in one of my program First is from ctime library,
And Second from Bash command "time"
Now as you can see one is exactly half of other. And i also computed time using stopwatch, it comes in favor of command "time". I am confused which is right? And its important. PS: if "time" is right, then suggest some commands to use that time in cpp code in runtime. | |||||
|
|
|||||
| ne555 (4042) | |
|
¿How is the `user' time longer than the `real' time? real: time spend between invocation and termination user: time that the process was executed. __Keep in mind that there are other process that your processor needs to take care of. So your program is not always executing. __By instance, if you try to read, or to output to the screen (that are slow devices) you process will be blocked till the operation fulfills. sys: ¿administration? (process creation, commutation, etc) ¿which one do you want? | |
|
|
|
| unkn00wn (68) | |
|
I want real time, i.e. the time i watched on stopwatch. Which is equal to time coming from "time" command. user time > real time... Because code is a parallel algorithm and i was working on cpu with two (cores) threads. Thus time(user)*2 is displayed! | |
|
|
|
| ne555 (4042) | |||||
|
I didn't think of that. Ok, I went trough the gnu-time source code. They use gettimeofday() in order to get microseconds precision.
| |||||
|
|
|||||
| unkn00wn (68) | |
| Thanks, It helps trigerring time. :) | |
|
|
|