News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

finstr timing example.

Started by hutch--, November 22, 2006, 12:04:09 AM

Previous topic - Next topic

hutch--

I was playing with an idea of JimG with the instring examples posted earlier and with a few mods, the algo seems to be a lot faster. The results surprised me and I checked the output to make sure there were no PH*K*PS and it seems to be working corectly and returning the corect values.

These are the results I am getting with the current test piece.



    707 timing msvcrt strstr
    99 timing finstr
    336 timing InStringL

    ----------------------
    706 average msvcrt strstr
    99 average finstr
    338 average InStringL
    ----------------------

Press any key to continue ...


I did the algo as two word sized reads rather than Jims suggestion of a single dword read as the ROL reg, 16 was a lot slower than the aditional word sized read and used a sequential add fall through rather than use jumps as 3 adds are still faster than a jump. My only comment is that the BYTE reads after a DWORD write may produce a stall on an older processor but this does not show up on either of my PIVs.

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PBrennick

These are my results:

Quote
AMD Athlon Processor
1.0 GHz. 256 MB of Ram

CPU speed =    999,624,549 Hz.

      Max =  1,000,424,610 Hz.
      Min =    994,376,847 Hz.
      Ave =    999,185,241 Hz.
   Spread = 6052.69 ppm

Number of tests =  13

Press any key to exit after current test.

Quote
    620 timing msvcrt strstr
    18 timing finstr
    340 timing InStringL

    ----------------------
    621 average msvcrt strstr
    18 average finstr
    339 average InStringL
    ----------------------

Press any key to continue ...

Very impressive, dude!  :thumbu
Paul
The GeneSys Project is available from:
The Repository or My crappy website

hutch--

Jim just found the error in the lst demoI posted, timed version had 0 instead of 1 for the starting position. I knew there was something wrong with it but could not find it.   :red
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Seb

Wow, I wasn't expecting these timings! Nice! :U



    634 timing msvcrt strstr
    17 timing finstr
    304 timing InStringL

    ----------------------
    632 average msvcrt strstr
    16 average finstr
    302 average InStringL
    ----------------------

hutch--

Seb,

You should have read the post before yours, the results were unusual and Jim found an error in the way the proc was called. Sad to say it was not that fast.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Seb


stanhebben

Little error :bg

Corrected benchmarks, for those wondering what's the difference between 0 and 1:



    628 timing msvcrt strstr
    413 timing finstr
    301 timing InStringL

    ----------------------
    628 average msvcrt strstr
    413 average finstr
    301 average InStringL
    ----------------------

Press any key to continue ...