Ilya Zakharevich on Wed, 25 Sep 2024 21:11:13 +0200


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

Re: Suspicious average timing of isprime() (maybe a bug?!)


On Tue, Sep 24, 2024 at 08:42:11PM +0200, Bill Allombert wrote:
> With isprime(,2) this is much slower and more bumpy.
> 
> 1e19    8563.500        45880
> 2e19    11670.000       44838
> 4e19    13109.000       44297
> 8e19    25932.000       43762
> 1e20    25657.500       43404
> 2e20    24775.000       42725
> 4e20    24289.500       42300
> 8e20    80724.000       41404
> 1e21    80930.500       41402
> 2e21    79912.000       40757
> 4e21    16539.500       40163
> 8e21    16324.500       39419
> 1e22    16730.000       39582
> 2e22    16481.500       38710
> 4e22    16556.500       38553
> 8e22    16372.500       37802
> 1e23    16268.500       37954
> 2e23    16179.000       37394
> 4e23    31847.500       36879
> 8e23    31660.500       36435

Where do you procure your adjectives from?  ;―)  I do not see anything
“bumpy”; it is a very smoothly changing timings — when the bug hits or
does not hit.  Just for your convenience, I reformat to make
small-vs-large more visible:

  perl -wlane "$F[1]=~s/^(?=[12]?\d{4}\.)/ /; print qq($F[0]\t$F[1]\t$F[2])" slow-isprime-bill

1e19     8563.500       45880
2e19     11670.000      44838
4e19     13109.000      44297

8e19     25932.000      43762
1e20     25657.500      43404
2e20     24775.000      42725
4e20     24289.500      42300
8e20    80724.000       41404
1e21    80930.500       41402
2e21    79912.000       40757
4e21     16539.500      40163
8e21     16324.500      39419
1e22     16730.000      39582
2e22     16481.500      38710
4e22     16556.500      38553
8e22     16372.500      37802
1e23     16268.500      37954
2e23     16179.000      37394
4e23    31847.500       36879
8e23    31660.500       36435

So: on each “run” it is very smooth.

Hope this helps,
Ilya