apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: [PATCH] vformatter cleanups (related to PR 42250)
Date Fri, 27 Apr 2007 13:31:47 GMT
Lucian Adrian Grijincu wrote:
> rather odd ... your new numbers say that all three versions are
> basically the same.
> It may be related to the processor architecture (your first tests were
> on a Intel(R) Celeron(R) CPU 2.20GHz).
> A test on that machine would say more about this.
> 
> William A. Rowe, Jr. wrote:
> 
>> nope - the proposed change is a bit more expensive.  (magnitude % 10 in
>> any case being the unavoidably most expensive bit.)
> 
> 
> On x86 the div instruction calculates both the reminder and the quotient
> in the same op.
> A good compiler may optimize these:
>     *--p = digits[magnitude % 10];
>      ((magnitude /= 10) != 0);
> into a single div instruction (see
> http://www.cs.tut.fi/~siponen/upros/intel/instr/div.html )
> 
> I'm not so sure about other processor architectures, but if all
> processors support such a feature, the third method
> may be faster than the first two (in combination with a good compiler).
> 
> If not, the original version, with a (magnitude*10), is better.

And it seems the original choice is still the best choice, until we gain
a inverted-tertiary div :)

> Anyways, it's not a critical function, in a tight loop somewhere :)

Wanna bet?  It was the difference between 18 hours and 30 hours per run
in at least one of my applications when generating 100,000 printed pages
(running on an IBM AT - and yes, 80286 did that nicely).  No, the 1987
compiler wasn't that clever, and yes, I rewrote the asm output from c.

     *--p = digits[magnitude % 10];
      ((magnitude /= 10) != 0);

What's the noop '!= 0' doing there?


Mime
View raw message