apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucian Adrian Grijincu <lucian.griji...@avira.com>
Subject Re: [PATCH] vformatter cleanups (related to PR 42250)
Date Fri, 27 Apr 2007 13:06:47 GMT
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.

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


-- 
Best regards,

Lucian Adrian Grijincu
Software Developer
Avira Soft srl

lucian.grijincu@avira.com
http://www.avira.com



Mime
View raw message