News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Test of timing code

Started by Antariy, May 08, 2013, 01:11:33 AM

Previous topic - Next topic

Antariy

Quote from: habran on May 09, 2013, 11:37:10 AM
Hey Antariy,
I appreciate your enthusiasm :t
I guess you must be a young man according to your energy level :biggrin:
   

Thanks :biggrin:
It's an Inspiration rather than enthusiasm :biggrin: We had told about unstable timings when it comes to very small count of cycles couple years ago, too. So, it's not a new topic here.

As for this method, there is the problem in that the CPUID instruction timings are unstable, this may sounds strange, but they are. If the CPUID in the timing frame gets executed faster than it was executed when computing an overhead, this makes too small or even negative values when computing the clock cycles. It seem possible to avoid influence of the OS and to get the code executed not too big number of times, but it is still the problems in the instability of CPU's behaviour, depending on the previous and the next code, relative to the currently executed one.

habran

maybe we should look at the average result rather than one execution result??? :idea:
it is frustrating that we can not force machine to do what we desire although we fuel it with ASM :icon13:


Cod-Father

Antariy

...and it makes to feel crazy when the machine shows that it is "too smart" :biggrin:

Yes, I think about range of results, not one average number, but something close to it by sense: two (or more) number which will show the probably range of the code speed, let's say: from 20 to 25 clocks at speed. It seem that getting exact number is not possible, and this becoming an issue when it comes to small cycles count (the light travelling half of a meter at the time that modern CPUs execute these 5 clocks :biggrin: :biggrin:). But it's better to have a range than nothing :lol:

habran

except if we want EVERYTHING OR NOTHING 8)
Cod-Father

Antariy

Hi all :biggrin:

Here is one more test, can I ask for the timings, please? Every hardware is welcome, since timings for now will be maybe a bit other as well as representation method is more comprehensive, but modern CPUs preferable, PIV and above, since there there is bigger instability of the timings.

Code now shows the "probability" values that mean the more big is the value the more big is probability of this clocks speed. If two values are near and are bigger that other ones, then this means that the peak of the graph is inbetween, atm the info is present in the "raw" format, actually it's the question how to implement the displayment, or to leave it as it is?

You may see sometimes unbelievable values, yes, there is even "0" clocks entries, but it's OK since the code just shows everything that is statistically possible, from 0 to maximally possible clocks for the algo. But, again, one value that is much larger that other ones is the peak which shows actual performance that was in that timing frame, or two near values that larger that other ones are the two points with the peak in the graph inbetween.

The point of this raw data is that being a humans we can easily drop the unbelievable timings, and choose ones which are suitable. I.e., if you see that the biggest probability is in zero cycles entry, or near that, with the algo that far from being just couple instructions long, then you will for sure find other one or two values that are large and much larger that other ones - those values are true, so, just drop the timing that was unbelievable. Remember, the code just shows everything, it does not bothers with checking how long the tested code is etc. As a proving of this - you may see that even if there are sometimes timings with too small clock number, the other, true, values are always the next largest ones, independ of the length of the shown table (i.e. number of entries for every result).


Well, there are much complications in the timing code isolation and still it is unstable, you may see that, for example, for my CPU, timing frame because of cpuid instruction has a wide bias from 456 clocks to the 536 clocks, and from the results you can see that it obviously has step of 8 clocks. As you see, there is 80 clocks difference (and that's too much for the algos that run not too big number of clocks), so it's no wonder that there are many false results - again, that's just everything that code founds "not bigger that it should be", next step - choose what is proper, is for the human.


One may play with a LOOP_COUNT equation in the start of listing, but increasing it well lead just "smoothing" the timings - too much loops obviously make CPU to become smart and we will again get something unbelievable results like ">20 instructions long, >12 of whose are non independed, algo of 2 clocks speed".

At least, for LOOP_COUNT = 3 it seem to work (probably ::)), maybe it a bit decreases actual timings, but with LOOP_COUNT = 1 the timings are a mess - because when LOOP_COUNT = 1 there are no passes done with the minimal set to closest to true speed, but if LOOP_COUNT set to too high value - there are too much loops, because CPU's logic comes to play. Maybe LOOP_COUNT = 2 is good, too, one may need to play with it for the particular machine.

Here are the results for the source in archive:

Intel(R) Celeron(R) CPU 2.13GHz (SSE3)

Min: 456, Max: 536, Ave: 530

Integer looped code test

RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16
RAW value: 512
        Probability of clock speed:
                0 clocks        59
                8 clocks        1
                16 clocks       11
                24 clocks       161
                32 clocks       5505
                40 clocks       1719
                48 clocks       1
                56 clocks       16


SSE code test

RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 504
        Probability of clock speed:
                0 clocks        1
                8 clocks        11
                16 clocks       161
                24 clocks       5505
                32 clocks       1719
                40 clocks       1
                48 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16


Almost empty test

RAW value: 480
        Probability of clock speed:
                0 clocks        5505
                8 clocks        1719
                16 clocks       1
                24 clocks       16
RAW value: 480
        Probability of clock speed:
                0 clocks        5505
                8 clocks        1719
                16 clocks       1
                24 clocks       16
RAW value: 480
        Probability of clock speed:
                0 clocks        5505
                8 clocks        1719
                16 clocks       1
                24 clocks       16
RAW value: 464
        Probability of clock speed:
                0 clocks        1
                8 clocks        16
RAW value: 480
        Probability of clock speed:
                0 clocks        5505
                8 clocks        1719
                16 clocks       1
                24 clocks       16
RAW value: 464
        Probability of clock speed:
                0 clocks        1
                8 clocks        16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 488
        Probability of clock speed:
                0 clocks        161
                8 clocks        5505
                16 clocks       1719
                24 clocks       1
                32 clocks       16
RAW value: 464
        Probability of clock speed:
                0 clocks        1
                8 clocks        16


Empty test

RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
RAW value: 472
        Probability of clock speed:
                0 clocks        1719
                8 clocks        1
                16 clocks       16
--- ok ---



This is a bit uncleaned version, just wanted to see how it behaves.
Testing and thoughts are welcome.

Now it should probably work as expected.

Many, many thanks to John who helped me a lot with testing this boring thing! :biggrin:

habran

                10 clocks       78723
                13 clocks       36931
                15 clocks       35993
                34 clocks       7844
                36 clocks       13347
RAW value: 96
        Probability of clock speed:
                0 clocks        32
                2 clocks        18
                4 clocks        221144
                6 clocks        374794
                8 clocks        231121
                10 clocks       78723
                13 clocks       36931
                15 clocks       35993
                34 clocks       7844
                36 clocks       13347
RAW value: 96
        Probability of clock speed:
                0 clocks        32
                2 clocks        18
                4 clocks        221144
                6 clocks        374794
                8 clocks        231121
                10 clocks       78723
                13 clocks       36931
                15 clocks       35993
                34 clocks       7844
                36 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 96
        Probability of clock speed:
                0 clocks        32
                2 clocks        18
                4 clocks        221144
                6 clocks        374794
                8 clocks        231121
                10 clocks       78723
                13 clocks       36931
                15 clocks       35993
                34 clocks       7844
                36 clocks       13347


Almost empty test

RAW value: 98
        Probability of clock speed:
                0 clocks        10
                2 clocks        32
                4 clocks        18
                6 clocks        221144
                8 clocks        374794
                10 clocks       231121
                12 clocks       78723
                15 clocks       36931
                17 clocks       35993
                36 clocks       7844
                38 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 98
        Probability of clock speed:
                0 clocks        10
                2 clocks        32
                4 clocks        18
                6 clocks        221144
                8 clocks        374794
                10 clocks       231121
                12 clocks       78723
                15 clocks       36931
                17 clocks       35993
                36 clocks       7844
                38 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347
RAW value: 100
        Probability of clock speed:
                0 clocks        6
                2 clocks        10
                4 clocks        32
                6 clocks        18
                8 clocks        221144
                10 clocks       374794
                12 clocks       231121
                14 clocks       78723
                17 clocks       36931
                19 clocks       35993
                38 clocks       7844
                40 clocks       13347


Empty test

RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 90
        Probability of clock speed:
                0 clocks        374794
                2 clocks        231121
                4 clocks        78723
                7 clocks        36931
                9 clocks        35993
                28 clocks       7844
                30 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 90
        Probability of clock speed:
                0 clocks        374794
                2 clocks        231121
                4 clocks        78723
                7 clocks        36931
                9 clocks        35993
                28 clocks       7844
                30 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
RAW value: 92
        Probability of clock speed:
                0 clocks        221144
                2 clocks        374794
                4 clocks        231121
                6 clocks        78723
                9 clocks        36931
                11 clocks       35993
                30 clocks       7844
                32 clocks       13347
--- ok ---
Cod-Father

jj2007

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)

Min: 264, Max: 264, Ave: 264

Integer looped code test

RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000
RAW value: 324
        Probability of clock speed:
                60 clocks       1000000


SSE code test

RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000


Almost empty test

RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000
RAW value: 288
        Probability of clock speed:
                24 clocks       1000000


Empty test

RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 276
        Probability of clock speed:
                12 clocks       1000000
RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 276
        Probability of clock speed:
                12 clocks       1000000
RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 264
        Probability of clock speed:
                0 clocks        1000000
RAW value: 276
        Probability of clock speed:
                12 clocks       1000000
RAW value: 276
        Probability of clock speed:
                12 clocks       1000000

hutch--

 :biggrin:

Now do you understand why I only ever clock an algo in real time ?  :P

MichaelW

The test procedures that Agner Fog provides here, include some DOS apps that switch to 32-bit protected mode to do cycle-count tests, then back to 16-bit real mode to display the results. Running under DOS has the advantages that you avoid the effects of multitasking and you can disable hardware interrupts, so at least in theory your test app can have exclusive use of the CPU. So hoping to get consistent and meaningful cycle counts in a single execution of the test code, I created a DOS test app. To simplify the task I used a FreeBASIC DOS app. FreeBASIC DOS creates 32-bit protected mode DOS apps that require a DOS Extender, and for this I used Japheth's HX DOS Extender. And I ran the test from an MS-DOS 6.22 boot diskette (if anybody here remembers what a diskette is).


#include "counter.bas"

dim as double d = 123

sleep 5000

asm cli

for i as integer = 1 to 40

    COUNTER_BEGIN( 1 )
        asm
            mov ebx, 1
            mov ecx, 8
            imul ebx, ecx
        end asm
    COUNTER_END()
    print counter_cycles;chr(9);

    COUNTER_BEGIN( 1 )
        asm
            mov ebx, 1
            mov ecx, 8
            imul ebx, ecx, 1
        end asm
    COUNTER_END()
    print counter_cycles;chr(9);

    COUNTER_BEGIN( 1 )
        asm
            mov eax, 1
            mov ecx, 8
            mul ecx
        end asm
    COUNTER_END()
    print counter_cycles;chr(9);

    COUNTER_BEGIN( 1 )
        asm
            mov eax, 123
            cdq
            mov ecx, 8
            div ecx
        end asm
    COUNTER_END()
    print counter_cycles;chr(9);

    COUNTER_BEGIN( 1 )
        asm
            fldpi
            fmul QWORD PTR [d]
            fstp QWORD PTR [d]
        end asm
    COUNTER_END()
    print counter_cycles;chr(9);

next

asm sti

sleep


As you can see in the above code the macro loop count is 1 so the macros are timing only a single pass through the test code.

Results running on my P3:

-52 1   4   36  21  4   4   4   47  26
4   4   -6  47  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   5   40  26  4   4   5   40  26
4   4   8   29  26  4   4   8   40  26
4   4   8   29  26  4   4   8   40  26
4   4   8   29  26  4   4   8   40  26
4   4   8   29  26  4   4   8   40  26
4   4   8   29  26  4   4   8   40  26
4   4   8   29  26  4   4   8   40  26


Running on my P4 Northwood:

12  12  12  76  1048 12 12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120
12  12  12  76  120 12  12  12  76  120


I don't know how to explain the variations at the start, or the other variations in the P3 results. And note in the P4 results that the counts are all a multiple of 4. I recall reading somewhere that for the NetBurst processors the TSC counts at the "quad-pumped" speed but updates at the FSB speed.

And note that the app will run fine under the Windows XP NTVDM, but on my P3 I get results like this:

260     129     53      67      180     15     -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      22
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -8      -6       40      21
4      -9      -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      22      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       40      21
4      -10     -6       40      47      4      -10     -6       40      21
4      -10     -6       40      21      4      -10     -6       47      21
4      -10     -6       40      21      4      -10     -6       40      21





Well Microsoft, here's another nice mess you've gotten us into.

Antariy

Thank you for test, habran and Jochen! :biggrin:


Quote from: hutch-- on May 11, 2013, 04:39:27 PM
:biggrin:

Now do you understand why I only ever clock an algo in real time ?  :P

Hi Hutch :biggrin:
Nothing wrong with this method - it works OK. The results are not "strange" but are just like scientifical - in the world of nanoseconds under OS there is no code which will measure clocks one by one, you know :biggrin: These results are strong statistics with as less possible loops under multitasking environment, and no any "guessing" or "fancy stuff".
So, real world performance will be something inbetween of the worst and the best values we get.

Test it, please, give one minute :t

And, yes, I vote for real time tests, too :t Timings are just thing to roughly see how good code performs, and especially when the code is not intended for processing big amounts of data. And this timing was specially intented to avoid the average method with many-many loops over the same data piece, when too much things depends on the CPU's prediction logic (BTW, this question was touched in the libraries vs WinAPI thread, too).


Michael, thank you for info and the code (had removed Win98 couple years ago, so obviously there is need in a boot diskette :biggrin:).

Antariy

Jochen, if you decrease LOOP_COUNT to 2, or even 1, what results do you get? Your CPU seems to be very stable with no bias in the timings of the timing code, so you obviously may try to decrease that equate, maybe this can give couple of cycles more precision :biggrin:

Antariy

Results for the Michael's EXE runned under XPSP2 NTVDM:

32      32     -576     56      1112    24      24      8       40      160
24      24      24      88      160     24      24      24      88      168
24      24      24      88      160     24      24      24      88      160
24      24      24      88      160     24      24      8       88      168
24      24      24      88      160     24      24      24      88      3640
24     -24      8       88      160     24      24      8       88      160
24      24      24      88      160     24      24      24      88      168
24      24      24      88      168     24      24      24      88      168
24      24      24      88      168     24      24      24      88      160
24      24      8       88      160     24      24      8       88      160
24      24      8       88      168     24      24      24      88      168
24      24      8       88      160     24     -24      24      88      168
24      24      8       88      168     24      24      24      88      160
24      24      8       88      168     24      24      24      88      168
24      24      24      88      168     24      24      8       88      168
24      24      24      88      160     24      24      24      88      168
24      24      8       88      168     24      24      24      88      160
24      24      24      88      168     24      24      24      88      168
24     -24      8       88      168     24      24      8       88      160
24      24      24      88      160     24      24      24      88      160


Gunther

Alex,

here are my results:


                26 clocks       3
                27 clocks       95389
                29 clocks       2
                30 clocks       117145
                31 clocks       1
                32 clocks       6
                33 clocks       351619
                34 clocks       3
                35 clocks       10
                36 clocks       199661
                37 clocks       13
                38 clocks       15
                40 clocks       13
                41 clocks       16704
                43 clocks       29
                44 clocks       23260
                46 clocks       36
                49 clocks       74
                52 clocks       102520
                55 clocks       80465
RAW value: 127
        Probability of clock speed:
                0 clocks        208
                3 clocks        185
                5 clocks        1
                6 clocks        261
                8 clocks        3
                9 clocks        95389
                11 clocks       2
                12 clocks       117145
                13 clocks       1
                14 clocks       6
                15 clocks       351619
                16 clocks       3
                17 clocks       10
                18 clocks       199661
                19 clocks       13
                20 clocks       15
                22 clocks       13
                23 clocks       16704
                25 clocks       29
                26 clocks       23260
                28 clocks       36
                31 clocks       74
                34 clocks       102520
                37 clocks       80465
RAW value: 145
        Probability of clock speed:
                0 clocks        18
                3 clocks        50
                6 clocks        88
                9 clocks        148
                12 clocks       157
                15 clocks       185
                18 clocks       208
                21 clocks       185
                23 clocks       1
                24 clocks       261
                26 clocks       3
                27 clocks       95389
                29 clocks       2
                30 clocks       117145
                31 clocks       1
                32 clocks       6
                33 clocks       351619
                34 clocks       3
                35 clocks       10
                36 clocks       199661
                37 clocks       13
                38 clocks       15
                40 clocks       13
                41 clocks       16704
                43 clocks       29
                44 clocks       23260
                46 clocks       36
                49 clocks       74
                52 clocks       102520
                55 clocks       80465
RAW value: 145
        Probability of clock speed:
                0 clocks        18
                3 clocks        50
                6 clocks        88
                9 clocks        148
                12 clocks       157
                15 clocks       185
                18 clocks       208
                21 clocks       185
                23 clocks       1
                24 clocks       261
                26 clocks       3
                27 clocks       95389
                29 clocks       2
                30 clocks       117145
                31 clocks       1
                32 clocks       6
                33 clocks       351619
                34 clocks       3
                35 clocks       10
                36 clocks       199661
                37 clocks       13
                38 clocks       15
                40 clocks       13
                41 clocks       16704
                43 clocks       29
                44 clocks       23260
                46 clocks       36
                49 clocks       74
                52 clocks       102520
                55 clocks       80465


Empty test

RAW value: 115
        Probability of clock speed:
                0 clocks        117145
                1 clocks        1
                2 clocks        6
                3 clocks        351619
                4 clocks        3
                5 clocks        10
                6 clocks        199661
                7 clocks        13
                8 clocks        15
                10 clocks       13
                11 clocks       16704
                13 clocks       29
                14 clocks       23260
                16 clocks       36
                19 clocks       74
                22 clocks       102520
                25 clocks       80465
RAW value: 118
        Probability of clock speed:
                0 clocks        95389
                2 clocks        2
                3 clocks        117145
                4 clocks        1
                5 clocks        6
                6 clocks        351619
                7 clocks        3
                8 clocks        10
                9 clocks        199661
                10 clocks       13
                11 clocks       15
                13 clocks       13
                14 clocks       16704
                16 clocks       29
                17 clocks       23260
                19 clocks       36
                22 clocks       74
                25 clocks       102520
                28 clocks       80465
RAW value: 104
        Probability of clock speed:
                0 clocks        16704
                2 clocks        29
                3 clocks        23260
                5 clocks        36
                8 clocks        74
                11 clocks       102520
                14 clocks       80465
RAW value: 118
        Probability of clock speed:
                0 clocks        95389
                2 clocks        2
                3 clocks        117145
                4 clocks        1
                5 clocks        6
                6 clocks        351619
                7 clocks        3
                8 clocks        10
                9 clocks        199661
                10 clocks       13
                11 clocks       15
                13 clocks       13
                14 clocks       16704
                16 clocks       29
                17 clocks       23260
                19 clocks       36
                22 clocks       74
                25 clocks       102520
                28 clocks       80465
RAW value: 115
        Probability of clock speed:
                0 clocks        117145
                1 clocks        1
                2 clocks        6
                3 clocks        351619
                4 clocks        3
                5 clocks        10
                6 clocks        199661
                7 clocks        13
                8 clocks        15
                10 clocks       13
                11 clocks       16704
                13 clocks       29
                14 clocks       23260
                16 clocks       36
                19 clocks       74
                22 clocks       102520
                25 clocks       80465
RAW value: 115
        Probability of clock speed:
                0 clocks        117145
                1 clocks        1
                2 clocks        6
                3 clocks        351619
                4 clocks        3
                5 clocks        10
                6 clocks        199661
                7 clocks        13
                8 clocks        15
                10 clocks       13
                11 clocks       16704
                13 clocks       29
                14 clocks       23260
                16 clocks       36
                19 clocks       74
                22 clocks       102520
                25 clocks       80465
RAW value: 118
        Probability of clock speed:
                0 clocks        95389
                2 clocks        2
                3 clocks        117145
                4 clocks        1
                5 clocks        6
                6 clocks        351619
                7 clocks        3
                8 clocks        10
                9 clocks        199661
                10 clocks       13
                11 clocks       15
                13 clocks       13
                14 clocks       16704
                16 clocks       29
                17 clocks       23260
                19 clocks       36
                22 clocks       74
                25 clocks       102520
                28 clocks       80465
RAW value: 115
        Probability of clock speed:
                0 clocks        117145
                1 clocks        1
                2 clocks        6
                3 clocks        351619
                4 clocks        3
                5 clocks        10
                6 clocks        199661
                7 clocks        13
                8 clocks        15
                10 clocks       13
                11 clocks       16704
                13 clocks       29
                14 clocks       23260
                16 clocks       36
                19 clocks       74
                22 clocks       102520
                25 clocks       80465
RAW value: 112
        Probability of clock speed:
                0 clocks        351619
                1 clocks        3
                2 clocks        10
                3 clocks        199661
                4 clocks        13
                5 clocks        15
                7 clocks        13
                8 clocks        16704
                10 clocks       29
                11 clocks       23260
                13 clocks       36
                16 clocks       74
                19 clocks       102520
                22 clocks       80465
RAW value: 118
        Probability of clock speed:
                0 clocks        95389
                2 clocks        2
                3 clocks        117145
                4 clocks        1
                5 clocks        6
                6 clocks        351619
                7 clocks        3
                8 clocks        10
                9 clocks        199661
                10 clocks       13
                11 clocks       15
                13 clocks       13
                14 clocks       16704
                16 clocks       29
                17 clocks       23260
                19 clocks       36
                22 clocks       74
                25 clocks       102520
                28 clocks       80465
--- ok ---


Gunther
You have to know the facts before you can distort them.

Antariy


Gunther

Hi Alex,

you're welcome, my friend.

Gunther
You have to know the facts before you can distort them.