Re: Best practice for data encoding?

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

 




Harald Alvestrand wrote:
> Ted Faber wrote:
> 
>> On Mon, Jun 12, 2006 at 02:11:19PM +0200, Iljitsch van Beijnum wrote:
>>  
>>
>>> The problem with text is that you have to walk through memory and 
>>> compare characters. A LOT.
>>>   
>>
>> That's not where your code spends its time.
>>
>> Run gprof(1).  The majority of time your code spends is spent doing the
>> 2 integer divides per text to integer conversion and in strtoimax
>> (called by fscanf).
>> Multiplying or dividing is the worst thing you can do on a CPU in
>> general.
> Note that CPUs are different; some multiply faster than others, compared
> to the rest of the HW.
> 
> And if you really need to, you can optimize... a multiplication by 10,
> for instance, can be done by two left shifts and an addition (a*10 = a
> <<3 + a<<1);

You might not end up with the same set of condition codes at the end,
though...

Joe


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________

Ietf@xxxxxxxx
https://www1.ietf.org/mailman/listinfo/ietf

[Index of Archives]     [IETF Annoucements]     [IETF]     [IP Storage]     [Yosemite News]     [Linux SCTP]     [Linux Newbies]     [Fedora Users]