Different deadlines for individual runs

I am creating a utility that will be used to compare different duplicate search algorithms. To pinpoint the runtime, I used the example I got from here . This is basically a function that returns the number of CPU ticks that have passed since the CPU started. I am not an expert in assembly, so I assume / hope the sample code is correct.

This is what my main function looks like.

int _tmain(int argc, _TCHAR* argv[])
{    
    // The size of the array that is going to be tested.
    int Size = 1000000;    
    int * Array = GenerateRandomArray(Size);

    // take a time measurement before.
    __int64 TicksBefore = GetCpuClocks();

    // Insert algorithm to benchmark here.
    for (int i = 0; i < 100; i++)
    {};

    // take a time measurement afterwords.
    __int64 TicksAfter = GetCpuClocks();

    // calculate the amount of ticks that has passed.
    __int64 TicksElapsed = TicksAfter - TicksBefore;

    cout << "\nThe amount of ticks that has elapsed for this operation is: " << TicksElapsed << endl;    

    return 0;
}

, , ? , 850 900, . GenerateRandomArray(Size), 1010 1200! . , .

, . / , , ?

+4
1

( TLB, ..)! , , t0, , , t1, .

~ 100 3 , TLB .. 3 4 ! C/++ , . , , "" , - .

- , , , "" , "" . , - , . , RDTSC, , . RDTSCP , , , CPU , , .

+4

Source: https://habr.com/ru/post/1540906/


All Articles