[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] seq: speed up the common case by 25x
From: |
Jim Meyering |
Subject: |
Re: [PATCH] seq: speed up the common case by 25x |
Date: |
Fri, 01 Apr 2011 11:59:05 +0200 |
Pádraig Brady wrote:
> On 01/04/11 10:20, Jim Meyering wrote:
>> Pádraig Brady wrote:
>>> seq: speed up the common case by 560%
>>>
>>> * seq.c (print_range): Print a range of numbers
>>> without using if statements for speed.
>>> (print_long_range): Print a range of numbers
>>> using the unix paradigm of using other utils
>>> that do it better.
>>
>> Great idea.
>
>> I get this:
>>
>> $ env time ./seq 10000000 > /dev/null
>> 0.50user 0.06system 0:00.20elapsed 273%CPU (0avgtext+0avgdata
>> 4800maxresident)k
>> ...
>>
>> Compare with the old version's time:
>>
>> 5.06user 0.00system 0:05.08elapsed 99%CPU (0avgtext+0avgdata
>> 2608maxresident)k
>>
>> So here I benefit from parallelism, and end up with not just 560% (5.6x)
>> but a 25x(!) speed-up (on an i7-970).
>
> My April fool's joke has spectacularly backfired.
Too close to the truth.
;-)
However, the point is very valid.
seq can and should be doing much better in that case.
Maybe librarify cat -n's code and use it from both?
We'd lose parallelism, but also skip the fork+inter-process I/O.