944,068 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 5513
  • C RSS
Jun 8th, 2007
0

to find the execution time of a code

Expand Post »
i have to find two time stamps one at the begining of main and at the end of main and take the difference to find the time elapsed to execute the code in between.Can anybody suggest the programs or proper API s in Linux.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shanthu123 is offline Offline
1 posts
since Jun 2007
Jun 8th, 2007
0

Re: to find the execution time of a code

>Can anybody suggest the programs or proper API s in Linux.
A profiler would be best. Check your system for the existence of gprof. You can also use a number of methods inside of your code to get execution time and timestamps, something like gettimeofday or rdtsc.
Last edited by Narue; Jun 8th, 2007 at 9:49 am.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jun 12th, 2007
0

Re: to find the execution time of a code

man time
time does what u want.
Reputation Points: 10
Solved Threads: 1
Light Poster
youngstorm is offline Offline
25 posts
since Jun 2007
Jun 13th, 2007
0

Re: to find the execution time of a code

Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jun 19th, 2007
0

Re: to find the execution time of a code

that thread had a post that the execution time varies with compiler.... is it true...... what exactly does change from compiler to compiler........
Last edited by aasi007onfire; Jun 19th, 2007 at 3:50 pm.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
aasi007onfire is offline Offline
22 posts
since Jun 2007
Jun 20th, 2007
0

Re: to find the execution time of a code

There shouldn't be a "major" difference due to compilers, it's more to do with the platform (OS+H/W) then compiler.
Using same compiler you can use different optimization levels, this should make a visible difference in performance.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: When I use a debugger if a have a function i go to assembly-it is not a bug
Next Thread in C Forum Timeline: Timing programs in C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC