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.

Recommended Answers

All 5 Replies

>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.

man time
time does what u want.

that thread had a post that the execution time varies with compiler.... is it true...... what exactly does change from compiler to compiler........

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.