coreutils
[Top][All Lists]
Advanced

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

Re: 70x speed-up for seq's common cases


From: Pádraig Brady
Subject: Re: 70x speed-up for seq's common cases
Date: Fri, 14 Sep 2012 15:57:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 09/14/2012 07:54 AM, Jim Meyering wrote:
Inspired by Pádraig's April-fools post,
   http://thread.gmane.org/gmane.comp.gnu.coreutils.general/972
and spurred by the fact that Torbjorn and Niels had to roll
their own seq-like program to test their new factoring code
(http://gmplib.org:8000/factoring), I have made coreutils' seq
usable for arbitrarily large, non-negative whole numbers.
This has two advantages:

     - correctness with large numbers
     - improved performance in common cases

For very large numbers, the new seq now appears to be correct:

     $ b=10000000000000000000000000000000000000000000000000000000000000
     $ src/seq ${b}09 ${b}11
     1000000000000000000000000000000000000000000000000000000000000009
     1000000000000000000000000000000000000000000000000000000000000010
     1000000000000000000000000000000000000000000000000000000000000011

while the old one would infloop, printing garbage:

     $ seq ${b}09 ${b}11 |head -2
     999999999999999999965225407341472151966654053379893968647487488
     999999999999999999965225407341472151966654053379893968647487488

This also means that nt-factor's tests can now use coreutils' seq
to generate their inputs.

Excellent :)

How about the attached follow up to enable the
fast code in more cases?

cheers,
Pádraig.

Attachment: seq-more-fast.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]