Created
December 1, 2010 21:42
-
-
Save kevroletin/724280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#include <math.h> | |
//---------- MEGA PROFILER ---------- | |
unsigned long long __time1, __time2, __dt, __min_dt, __time_total; | |
#define TEST_HEAD_EX(REPEAT_TIMES)\ | |
__min_dt = 0xffffffff;\ | |
__time_total = 0;\ | |
for (int __i = 0; __i < REPEAT_TIMES; ++__i)\ | |
{\ | |
#define TEST_START_EX \ | |
asm volatile (\ | |
"lfence;"\ | |
"rdtsc;"\ | |
"movl %%eax, __time1;"\ | |
"movl %%edx, __time1+4;"\ | |
"lfence;" \ | |
:\ | |
:\ | |
:"edx", "eax"\ | |
);\ | |
#define TEST_FIN_EX(OVERHEAD, MIN, TOTAL)\ | |
asm volatile (\ | |
"lfence;"\ | |
"rdtsc;"\ | |
"movl %%eax, __time2;"\ | |
"movl %%edx, __time2+4;" \ | |
:\ | |
:\ | |
:"edx", "eax"\ | |
);\ | |
__dt = __time2 - __time1 - OVERHEAD;\ | |
__time_total += __dt;\ | |
if (__dt < __min_dt) __min_dt = __dt;\ | |
}\ | |
MIN = __min_dt;\ | |
TOTAL = __time_total;\ | |
//-------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment