954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C coding

Hi everybody,

Can anyone among you let me know.how can i find execution time of an algorithm in my c coding!!

thanks

Nalini

nalinibh
Newbie Poster
10 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

If your using Linux the "time" command will do nicely.

youngstorm
Light Poster
25 posts since Jun 2007
Reputation Points: 10
Solved Threads: 1
 

Hello

sorry i have not mentionned, i am using winxp and running in command mode.

thanks

nalini

nalinibh
Newbie Poster
10 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 
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
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Ancient Dragon

time is a command.
usage: time
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.

youngstorm
Light Poster
25 posts since Jun 2007
Reputation Points: 10
Solved Threads: 1
 

Ancient Dragon

time is a command. usage: time


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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You