diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/tool.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/tool.h b/tools/tool.h index 47155c2..c6fafbc 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -22,6 +22,40 @@ log_stderr(const char *str, void *unused) | |||
| 22 | fprintf(stderr, "%s", str); | 22 | fprintf(stderr, "%s", str); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | #ifdef _WIN32 | ||
| 26 | |||
| 27 | #include <windows.h> | ||
| 28 | |||
| 29 | static double | ||
| 30 | timerun(void (*run)(void)) | ||
| 31 | { | ||
| 32 | LARGE_INTEGER freq, start, end; | ||
| 33 | double tdiff; | ||
| 34 | |||
| 35 | fflush(stdout); | ||
| 36 | |||
| 37 | if (run == NULL) { | ||
| 38 | printf("nothing to run!\n"); | ||
| 39 | fflush(stdout); | ||
| 40 | return -1.0; | ||
| 41 | } | ||
| 42 | |||
| 43 | QueryPerformanceFrequency(&freq); | ||
| 44 | QueryPerformanceCounter(&start); | ||
| 45 | run(); | ||
| 46 | QueryPerformanceCounter(&end); | ||
| 47 | |||
| 48 | tdiff = (double)(end.QuadPart - start.QuadPart) / freq.QuadPart; | ||
| 49 | |||
| 50 | printf("---------\n"); | ||
| 51 | printf("\nTotal time: %.4fs\n", tdiff); | ||
| 52 | fflush(stdout); | ||
| 53 | |||
| 54 | return tdiff; | ||
| 55 | } | ||
| 56 | |||
| 57 | #else | ||
| 58 | |||
| 25 | static double | 59 | static double |
| 26 | timerun(void (*run)(void)) | 60 | timerun(void (*run)(void)) |
| 27 | { | 61 | { |
| @@ -51,6 +85,8 @@ timerun(void (*run)(void)) | |||
| 51 | return tdiff; | 85 | return tdiff; |
| 52 | } | 86 | } |
| 53 | 87 | ||
| 88 | #endif | ||
| 89 | |||
| 54 | static void | 90 | static void |
| 55 | writetable(const unsigned char *buf, int64_t size, const char *filename) | 91 | writetable(const unsigned char *buf, int64_t size, const char *filename) |
| 56 | { | 92 | { |
