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

John Morris jmorris at beau.org
Sat Feb 27 05:00:31 UTC 2016


On Fri, 2016-02-26 at 12:06 -0600, Ranjan Maitra wrote:
> Thank you! So, is there any way that these other processes can be 
> separated out in the time calculations? I can not come up with 
> definitive statements unless I can do these comparisons in a fair 
> manner.

Not really.  The days of purely deterministic computing are long gone.
What you can do is what most benchmarks do, run the program many times
and calculate an average time.  Depending what your program does though
you may have to take steps to ensure the second and later runs are
truly representative such as making sure nothing is still cached in theCPU cache, pages purged in memory, residing in the disc cache, etc. Be sure to consider everything that might make the second run go faster than the first.

Those sort of issues are why the literature on benchmarking gets
complicated really fast.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.fedoraproject.org/pipermail/users/attachments/20160226/0c6f5e04/attachment.sig>


More information about the users mailing list