Author Topic: New timing macros  (Read 2855 times)

jj2007

  • Member
  • *****
  • Posts: 13299
  • Assembly is fun ;-)
    • MasmBasic
Re: New timing macros
« Reply #45 on: May 24, 2022, 08:51:52 AM »
if you can see the program running fast then you finished the job.

Sure, but between starting the work and finishing, there may be weeks or years. In the meantime, you might want to know which instructions are the fastest in the 100+ innermost loops of your program. For example, are inc, add and lea any different? Should you prefer one of them? Does one of them really suck on AMD cpus, or on the cheap Celerons that your company uses?

Code: [Select]
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
once:
0        Cycles for inc eax
0        Cycles for add eax,1
0        Cycles for lea eax,[eax+1]
0        Cycles for inc eax
0        Cycles for add eax,1
0        Cycles for lea eax,[eax+1]
0        Cycles for inc eax
0        Cycles for add eax,1
0        Cycles for lea eax,[eax+1]
0        Cycles for inc eax
0        Cycles for add eax,1
0        Cycles for lea eax,[eax+1]

100x:
87       Cycles for 100*inc eax
96       Cycles for 100*add eax,1
84       Cycles for 100*lea eax,[eax+1]
84       Cycles for 100*inc eax
81       Cycles for 100*add eax,1
83       Cycles for 100*lea eax,[eax+1]
84       Cycles for 100*inc eax
85       Cycles for 100*add eax,1
84       Cycles for 100*lea eax,[eax+1]
84       Cycles for 100*inc eax
78       Cycles for 100*add eax,1
84       Cycles for 100*lea eax,[eax+1]
1 bytes for inc eax
3 bytes for add eax, 1
3 bytes for lea eax, [eax+1]
100 bytes for 100*inc eax
300 bytes for 100*add eax, 1
300 bytes for 100*lea eax, [eax+1]

felipe

  • Member
  • *****
  • Posts: 1381
Re: New timing macros
« Reply #46 on: May 24, 2022, 09:40:44 AM »
Actually that's a good point jj. You will need to test during the development. How you test performance specifically i suppose will always be a function (at least) of the type of program you are doing.