Skip to content

Instantly share code, notes, and snippets.

@tanakamura
Created February 1, 2014 06:45
Show Gist options
  • Save tanakamura/8748818 to your computer and use it in GitHub Desktop.
Save tanakamura/8748818 to your computer and use it in GitHub Desktop.
/*
* i7-4700MQ Win8.1 : 9533.579865clk
*/
#include <windows.h>
#include <setjmp.h>
#define NUM (4096*8)
volatile int counter = 0;
jmp_buf jbuf;
LONG WINAPI handler(struct _EXCEPTION_POINTERS *exc)
{
counter++;
longjmp(jbuf, 1);
}
static void
bench(void)
{
int *p;
counter = 0;
setjmp(jbuf);
if (counter == NUM) {
return;
}
p = 0;
*p = 0;
}
int main()
{
PVOID h;
int t0, t1;
h = AddVectoredExceptionHandler(1, handler);
bench();
t0 = __rdtsc();
bench();
t1 = __rdtsc();
printf("%f\n", (t1-t0)/(double)NUM);
RemoveVectoredExceptionHandler(h);
puts("done");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment