-
-
Save tanakamura/23397b1d9de969ced2130d6ed90d8226 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
| #define UNICODE | |
| #include <windows.h> | |
| #include <stdio.h> | |
| double f_freq; | |
| double | |
| getsec(void) | |
| { | |
| LARGE_INTEGER v; | |
| QueryPerformanceCounter(&v); | |
| return v.QuadPart / f_freq; | |
| } | |
| int main() | |
| { | |
| LARGE_INTEGER freq; | |
| QueryPerformanceFrequency(&freq); | |
| f_freq = freq.QuadPart; | |
| double t0, t1; | |
| FILE *a = fopen("a.txt", "wb"); | |
| fclose(a); | |
| HANDLE h = CreateFile(TEXT("a.txt"), | |
| GENERIC_READ | GENERIC_WRITE, | |
| 0, | |
| NULL, | |
| OPEN_ALWAYS, | |
| 0, | |
| NULL); | |
| CloseHandle(h); | |
| for (int i=0; i<4; i++) { | |
| int nloop = 4096; | |
| t0 = getsec(); | |
| for (int li=0; li<nloop; li++) { | |
| HANDLE h = CreateFile(TEXT("a.txt"), | |
| GENERIC_READ | GENERIC_WRITE, | |
| 0, | |
| NULL, | |
| OPEN_ALWAYS, | |
| 0, | |
| NULL); | |
| CloseHandle(h); | |
| } | |
| t1 = getsec(); | |
| printf("%f[usec]\n", ((t1-t0)/nloop)*1000000.0); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment