Bill Allombert on Sun, 30 Sep 2012 13:27:19 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
timing in GP |
Dear PARI developers, There are various issues with the timers in GP. 1) the #/## interface: The problem with # is that it print the time _before_ the result. If your result is larger than the terminal, then you do not see it. The problem with ## is that you can forget to do it until it is too late. Maybe we could store the timing in the % history alongside the result, a provide a command to retrieve it (e.g. %#n) 2) the gettime interface: The problem is that it is not reentrant. Let say you write functions: zet(N,s)=gettime();my(s=sum(n=1,N,n^-s));print("sum:",gettime());s vecz(N,n)=gettime();my(v=vector(n,t,zet(N,.5+I*t)));print("vec:",gettime());v You get: ? vecz(10000,10); sum:253 sum:251 sum:251 sum:252 sum:251 sum:251 sum:251 sum:252 sum:251 sum:251 vec:1 The final time is wrong. We should provide a version of gettime that return the time in microseconds since the start of the GP session so we could do t=gettime2();....;print(gettime2()-t; We could also provide a function printtime(t,s,...) which would do printtime("Time ",s," :",gettime2()-t); Cheers, Bill.