Re: Skybuck's TryStrToUint64 (Version 0.03, register/simple version)



Here is the main loop one more time by simply using the Borland/Common
Technique it seems:

// Since the checks are down up top... the multiplication should be safe :)

I am not sure if all the memory look ups from the previous versions would be
fast... so here is an alternative version
which is very simply code by using an extra multiplication, no lookup
tables, and even simpler index handling.

So there are now three different versions to choose from.

Which one is the fastest is hard to say... it might be different per machine
even...

So a benchmark would have to prove which one is fastest ;)

But I am not so much interested in benchmarking and performance.

As long as it's decent performance it's ok.

And the multiplication will probably be pretty fast in true 64 bit mode...

For now it's emulated mode which reduces it's speed a little bit.

For those people interested in assembler and machine workings and string
conversion speeds take your pick and benchmark !

However I have other things to do for now.... and I just need this
conversion routine for some debugging purposes ;)

So speed not an issue for me, at least not today ! ;)

// simple main conversion loop:

// if code reaches here then ok, convert it
for vIndex := 1 to Length(S) do
begin
// Value := Value + (DigitValue[S[Length(S)-(vIndex-1)]] *
DigitPositionValue[vIndex]);

// possible optimization, which uses larger memory table no more multiply:
// maybe all these memory access in 32 bit land not so fast/good so
instead try using
// registers ;)
// Value := Value + DigitPositionValue[S[Length(S)-(vIndex-1)]][vIndex];

// simplest code:
Value := Value * 10 + DigitValue[S[vIndex]];

end;

Bye,
Skybuck.


.



Relevant Pages

  • Re: Why is C# 450% slower than C++ on nested loops ??
    ... The posted benchmark was crucial to ... > compilers generate for the loop and get over with it. ... > additions in the outer loops, which the C# compiler doesn't. ... gotten around to implementing every possible optimization in every language, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Faster HexToBuffer Routines
    ... Here is a WORKING unrolled loop version of my routine. ... Unrolling the loop, of course, speeds things up ... most of the string instructions ...
    (alt.lang.asm)
  • Re: Bit-order reversal (little-endian <--> big-endian)
    ... The only thing I did with your do loop is ... copy and paste it into a benchmark app. ... Certainly you can use a standard if then statement instead of the IIF. ... design is faster as it avoids extra iterations. ...
    (microsoft.public.vb.general.discussion)
  • Re: OT - internet speeds - a question.
    ... blame for shit connectivity - although they'll tell you otherwise. ... "The services enabled customers to get up to 8Mbit speeds downstream, ... the exchange loop. ...
    (uk.politics.misc)
  • Re: Two Click disassembly/reassembly
    ... :4 to EAX on each iteration of that loop. ... currently writing a conversion tool. ... As you may know, some years ago, I wrote a text adventure game engine, for ... However, the 16 hours, or so, which I have spent writing the ...
    (alt.lang.asm)