Bill Allombert on Sun, 03 Jun 2012 11:13:20 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: clock_gettime |
On Sun, Jun 03, 2012 at 01:19:57AM +0200, Loïc Grenié wrote: > Hi pari developers, > > a patch has just been submitted to allow for a different timing function: > clock_gettime. The accuracy of timing in libpari is 1ms. Under linux, > getrusage and times accuracy are limited by kernel HZ constant which means > that accuracy is 10ms if HZ=100, 4ms if HZ=250 or 1ms if HZ=1000. > clock_gettime however has the accuracy of the underlying hardware clock, > but the system call is slightly more costly. > > If you need better accuracy (and can spend ~15% more in clock_gettime than > in getrusage) you can use clock_gettime. Otherwise just stick with the > default. Two comments: 1) To use it, you need to do ./Configure --time=clock_gettime and if you want to skip 'make clean': touch src/language/init.c 2) on paridev at least the penalty is much larger that 15%: getrusage: ? for(i=1,10^7,gettime()) ? ## *** last result computed in 808 ms. clock_gettime: ? for(i=1,10^7,gettime()) ? ## *** last result computed in 2,262 ms. given the overhead of an empty loop is about 360ms, this give 448ms for getrusage against 1902ms, so this is four time slower (under GP, in C it should be worse). Of course this is irrelevant if you only do a couple of gettime calls and this give much more stable results. Cheers, Bill.