Re: OT: recommended way of timing two pieces of code in C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 02/26/2016 05:41 PM, Patrick O'Callaghan wrote:
On Fri, 2016-02-26 at 17:31 -0700, jd1008 wrote:
On 02/26/2016 05:28 PM, Ranjan Maitra wrote:
Thanks again!

OK, is there a way to calculate the FLOP instructions in C?
What do you mean "calculate the FLOP instructions"? Are you
trying to
evaluate an algorithm or benchmark an implementation? These are
two
different things. You can compare algorithms theoretically or by
measurement, but only measurement will work for implementations.
You
can count each floating point instruction generated by the
compiler by
looking at the binary code, but maybe you want to count every
instruction during execution, or see which instructions take
longer, or
just measure the total execution time of the algorithm on a given
set
of input.
Indeed, I wanted to measure the total execution time of the
algorithms (i.e. difference in CPU time after and before the
function executing the algorithm is called) and independent of
extraneous issues such as what other process is running at some
time, etc. I wanted to see if, in some case, some of the available
theoretical guarantees actually hold or not.

Thanks again!

Best wishes,
Ranjan

Did you see my reply?
It shows you the basics of what you need to use
in order to get exactly what you want.
Note that the accuracy of this depends on several factors, such as how
long the measured interval is compared to the basic unit of timekeeping
(IOW if you want to measure the execution time of a short sequence of
instructions, you need to loop a few million times and divide the
result), and how much overhead is incurred in calling the timing
routines.

poc
Hi Patrick.
Actually, no.
Since the virtual timer is incremented only while the process is actually running on the cpu, the time difference from when you first "start" the timer, and when you "stop" the timer (in Ranjan's case, just before exit), gives the most accurate time possible on a system like linux. What Ranjan can do also, is to set the process scheduling class to REALTIME (which is as approximate to REALTIME as a multiuser virtual mem system can provide). Thus he will get a very accurate benchmark for the segment of code he wants to measure.

--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux