Hi everybody,
Can anyone among you let me know.how can i find execution time of an algorithm in my c coding!!
thanks
Nalini
one way is to buy a commercial profiler program :)
But the easiest way is to call clock() to get the current time before starting the algorithm, then call it again after the algorithm is finished. The difference is the execution time. But be warned that the algorithm might execute so quickly that the time is unmeasurable. In that case call the algorithm in a loop for maybe a thousand or so times.
If your using Linux the "time" command will do nicely.
Hello
sorry i have not mentionned, i am using winxp and running in command mode.
thanks
nalini
If your using Linux the "time" command will do nicely.
time() resolution is only to 1 second -- not accurate enough for profiling. clock() however normally has a resolution of 1 millisecond.
Ancient Dragon
time is a command.
usage: time <command>
It gives cpu, mem and IO info.
It does do millisecond info also, I just tryed it.
For info do 'man time'
I don't know if time has been ported to Windoze.
Ancient Dragon
time is a command.
usage: time <command>
Oh. I thought you were talking about the time functions in time.h
know if time has been ported to Windoze.
I don't think so.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.