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! . , .
GenerateRandomArray(Size)
, . / , , ?
( TLB, ..)! , , t0, , , t1, .
~ 100 3 , TLB .. 3 4 ! C/++ , . , , "" , - .
- , , , "" , "" . , - , . , RDTSC, , . RDTSCP , , , CPU , , .
RDTSC
RDTSCP
Source: https://habr.com/ru/post/1540906/More articles:weird rejection using stringstream to read float value - c ++Absolute Centered Div Quirks Between IE and Chrome - htmlIs it possible to open the application from the launch of the bot Xcode script - iosChanging laravel remember_token field to something else - authenticationNSWorkspace launchApplication: crash on first run as root - objective-cAdd custom cordova plugin to IBM Worklight 6.1 - pluginsHow to access environment variables on a JSP page - javaReaches values between two jsp with jstl - javaAutomatic parameterized constructor selection when deserializing JsonCovertor - jsonIs there a transpose function in Elixir? - elixirAll Articles