Author Topic: Timings for a Masm64 SDK test  (Read 1262 times)

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Timings for a Masm64 SDK test
« on: July 05, 2022, 02:32:00 AM »
Code: [Select]
    invoke InstrJB, "The haystack: does it really contain a needle?", "needle"
    conout "The needle is at pos ", str$(rdx), lf
    invoke InstrCrt, "The haystack: does it really contain a needle?", "needle"
    conout "The needle is at pos ", str$(rdx), lf
    invoke FindStr, 1, "The haystack: does it really contain a needle?", "needle"
    conout "The needle is at pos ", str$(rax), lf

The attached exe needs the DLL (with JBasic Instr + crt strstr) in the same folder. Thanks for some timings (it looks for the string "WARNING Duplicate" in Windows.inc)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #1 on: July 05, 2022, 03:10:14 AM »
jj,

I can download from the link but the file is 0 length.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #2 on: July 05, 2022, 03:45:15 AM »
Strange, for me it works fine. 4 files in the archive, all ok...

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #3 on: July 05, 2022, 04:29:37 AM »
Downloaded it with Chrome.

A:\jj\test>jjapp
The needle is at pos 40
The needle is at pos 40
The needle is at pos 40
WARNING at pos 977313, and it took 46 ms with InstrJB
WARNING at pos 977313, and it took 844 ms with InstrCrt
WARNING at pos 977313, and it took 844 ms with FindStr
bye
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 2263
  • AMD 7-32 / i3 10-64
Re: Timings for a Masm64 SDK test
« Reply #4 on: July 05, 2022, 07:36:16 AM »
Code: [Select]
The needle is at pos 40
The needle is at pos 40
The needle is at pos 40
WARNING at pos 978042, and it took 47 ms with InstrJB
WARNING at pos 978042, and it took 828 ms with InstrCrt
WARNING at pos 978042, and it took 828 ms with FindStr
bye
Equations in Assembly: SmplMath

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #5 on: July 05, 2022, 07:38:25 AM »
WARNING at pos 978042

You fumbled your Windows.inc, Hector :biggrin:

Thanks, guys :thumbsup:

HSE

  • Member
  • *****
  • Posts: 2263
  • AMD 7-32 / i3 10-64
Re: Timings for a Masm64 SDK test
« Reply #6 on: July 05, 2022, 07:58:32 AM »
You fumbled your Windows.inc

I have 27 Windows.inc files  :biggrin:
Equations in Assembly: SmplMath

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #7 on: July 06, 2022, 06:10:46 PM »
jj,

Something weird with your demo, I have timed FindStr which is an ordinary byte scanner on the win32 windows.inc file and on my old Haswell, I get this result. It is too fast for a file of that length returning 0 ms.

len = 977313 bytes
 timing in ms = 0

 thats all folks ....

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    include \masm64\include64\masm64rt.inc

    .code

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

 entry_point proc

    USING r12
    LOCAL pMem  :QWORD
    LOCAL rslt  :QWORD
    LOCAL tcnt  :QWORD

    SaveRegs

    mov pMem, loadfile("windows.inc")

    rcall GetTickCount
    mov r12, rax

    mov rslt, rvcall(FindStr,1,pMem,"WARNING Duplicate include file windows.inc")

    rcall GetTickCount
    sub rax, r12
    mov r12, rax

    conout " len = ",str$(rslt)," bytes",lf

    conout " timing in ms = ",str$(r12),lf,lf

    mfree pMem

    waitkey " thats all folks ...."
    RestoreRegs
    .exit

 entry_point endp

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    end
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #8 on: July 06, 2022, 06:18:23 PM »
Hutch,

I don't think it's too fast, but there is indeed a glitch - I forgot to re-initialise the counter for FindStr (see attached new version):
Code: [Select]
    iterations=1000
    mov r12d, iterations
    mov r13, rv(GetTickCount)
@@: invoke FindStr, 1, pMem, "WARNING Duplicate"
dec r12d
jge @B
    conout "WARNING at pos ", str$(rax)
    sub rv(GetTickCount), r13
    conout ", and it took ", str$(rax), " ms with FindStr", lf

I had already wondered why the CRT and FindStr timings were always identical :rolleyes: :sad:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #9 on: July 06, 2022, 09:18:44 PM »
I have timed the example correctly and with a less than 1 meg file it did not get above the base granularity of GetTickCount. The algo is fast enough for general purpose search, there may be a trick with one of the new SSE4.2 instructions but I have not seen it done yet.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #10 on: July 06, 2022, 09:22:59 PM »
I have timed the example correctly

With iterations=1000?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #11 on: July 06, 2022, 09:26:07 PM »
Your results are not making sense, this is what I get.

The needle is at pos 40
The needle is at pos 40
The needle is at pos 40
WARNING at pos 977313, and it took 46 ms with InstrJB
WARNING at pos 977313, and it took 891 ms with InstrCrt
WARNING at pos 977313, and it took 703 ms with FindStr
bye

My timing has no errors in it, and it does not get over the base granularity of GetTickCount. I have no idea of what you have done with the timing as your DLL source is not available.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #12 on: July 06, 2022, 09:29:20 PM »
It does 1000 iterations in the loop:

Code: [Select]
    mov r12d, iterations
    mov r13, rv(GetTickCount)
@@: invoke FindStr, 1, pMem, "WARNING Duplicate"
dec r12d
jge @B
    conout "WARNING at pos ", str$(rax)
    sub rv(GetTickCount), r13

Your timings look entirely plausible - your machine is just a lot faster than mine:

Code: [Select]
WARNING at pos 977313, and it took 94 ms with InstrJB
WARNING at pos 977313, and it took 1888 ms with InstrCrt
WARNING at pos 977313, and it took 1170 ms with FindStr

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10031
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Timings for a Masm64 SDK test
« Reply #13 on: July 06, 2022, 09:42:54 PM »
Here is the 1000 loop test piece. On my old Haswell I get 609 ms. I have no idea of what you are doing with the other two algos as your source is closed.

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    include \masm64\include64\masm64rt.inc

    .code

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

 entry_point proc

    USING r12,r13
    LOCAL pMem  :QWORD
    LOCAL rslt  :QWORD
    LOCAL tcnt  :QWORD

    SaveRegs

    mov pMem, loadfile("windows.inc")

  ; ------------------------------------------------

    mov r13, 1000

    rcall GetTickCount
    mov r12, rax

  lbl:
    mov rslt, rvcall(FindStr,1,pMem,"WARNING Duplicate include file windows.inc")
    sub r13, 1
    jnz lbl

    rcall GetTickCount
    sub rax, r12
    mov r12, rax

  ; ------------------------------------------------

    conout " len = ",str$(rslt)," bytes",lf

    conout " timing in ms = ",str$(r12),lf,lf

    mfree pMem

    waitkey " thats all folks ...."
    RestoreRegs
    .exit

 entry_point endp

; «»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»

    end
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13336
  • Assembly is fun ;-)
    • MasmBasic
Re: Timings for a Masm64 SDK test
« Reply #14 on: July 06, 2022, 10:09:11 PM »
as your source is closed

I am sorry for that. The point is that there are some individuals here, mainly Germans, who do hardly any coding but love to make fun of MasmBasic. One of them insults me frequently. Another one has 40 posts but never posted a single line of code.

I have always shared my code in the past, but I can't do so any more, knowing that these individuals would not hesitate to grab my sources, modify a line or to and then declare it their own work.

WARNING at pos 977313, and it took 703 ms with FindStr
On my old Haswell I get 609 ms

That's quite a difference between your first and second test - same cpu?