Skip to content

Instantly share code, notes, and snippets.

@tanakamura
Created September 3, 2016 06:19
Show Gist options
  • Save tanakamura/17f8ef87bfd82c25e50fb4880c554b68 to your computer and use it in GitHub Desktop.
Save tanakamura/17f8ef87bfd82c25e50fb4880c554b68 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
int main() {
int nloop = 1024, i;
LARGE_INTEGER freq, t0, t1;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&t0);
for (i=0; i<nloop; i++) {
STARTUPINFO sp = {0};
PROCESS_INFORMATION pi;
sp.cb = sizeof(sp);
CreateProcess(TEXT("exit2.exe"),
TEXT(""),
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&sp,
&pi);
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
}
QueryPerformanceCounter(&t1);
printf("%f\n", (t1.QuadPart-t0.QuadPart) / ((double)(freq.QuadPart)*nloop));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment