Created
February 1, 2014 06:59
-
-
Save tanakamura/8749044 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* i7-4700MQ Win8.1 : 9533.579865clk | |
* i7-4700MQ Linux 3.11.4-201.fc19.x86_6 : 1815.603760 | |
*/ | |
#include <signal.h> | |
#include <setjmp.h> | |
#include <x86intrin.h> | |
#include <stdio.h> | |
#define NUM (4096*8) | |
volatile int counter = 0; | |
sigjmp_buf jbuf; | |
void handler(int n) | |
{ | |
counter++; | |
siglongjmp(jbuf, 1); | |
} | |
static void | |
bench(void) | |
{ | |
int *p; | |
counter = 0; | |
sigsetjmp(jbuf, 1); | |
if (counter == NUM) { | |
return; | |
} | |
p = 0; | |
*p = 0; | |
} | |
int main() | |
{ | |
int t0, t1; | |
signal(SIGSEGV, handler); | |
perror("signal"); | |
bench(); | |
t0 = __rdtsc(); | |
bench(); | |
t1 = __rdtsc(); | |
printf("%f\n", (t1-t0)/(double)NUM); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment