LoÃc Grenià on Sun, 30 Sep 2012 22:18:06 +0200


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

Re: timing in GP


2012/9/30 Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>:
> 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)

    That would be nice.

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

    I think getabstime() or something similar would be better but in general
  it's a good idea.

> We could also provide a function printtime(t,s,...) which would do
> print("Time ",s," :",gettime2()-t);

    Is it really necessary ?

         Thanks,

                 LoÃc