Bill Allombert on Thu, 03 Jul 2025 09:20:33 +0200


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

Re: question on execution time for qfbsolve


On Wed, Jul 02, 2025 at 08:14:09PM -0700, American Citizen wrote:
> I ran over the first 100,000 integers
> 
> ? for(i=1,100000,qfbsolve(Qfb(1,0,1),i,3))
> cpu time = 3,394 ms, real time = 3,394 ms.
> ? for(i=1,100000,qfbsolve(Qfb(1,0,1),[i,factor(i)],3))
> cpu time = 3,348 ms, real time = 3,348 ms.
> 
> so it is about the same, not much improvement, 46 milliseconds.

Of course since you are including the time to factor i!

The point is to avoid factoring i again when its factorization is already
known.

For example:

? #
? forfactored(i=1,1000000,qfbsolve(Qfb(1,0,1),i,3))
  ***   last result computed in 2,767 ms.
? for(i=1,1000000,qfbsolve(Qfb(1,0,1),i,3))
  ***   last result computed in 2,994 ms.
? for(i=1,1000000,qfbsolve(Qfb(1,0,1),[i,factor(i)],3))
  ***   last result computed in 3,131 ms.

Of course for small numbers, it should not make a lot of difference.

Cheers,
Bill.