diff options
Diffstat (limited to '')
| -rw-r--r-- | tools/tool.h | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/tools/tool.h b/tools/tool.h index c44828d..9fee050 100644 --- a/tools/tool.h +++ b/tools/tool.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | static void log_stderr(const char *, ...); | 11 | static void log_stderr(const char *, ...); |
| 12 | static void log_stdout(const char *, ...); | 12 | static void log_stdout(const char *, ...); |
| 13 | static double timerun(void (*)(void), const char *); | 13 | static double timerun(void (*)(void)); |
| 14 | static void getfilename(const char *, const char *, char *); | 14 | static void getfilename(const char *, const char *, char *); |
| 15 | static void writetable(const char *, int64_t, const char *); | 15 | static void writetable(const char *, int64_t, const char *); |
| 16 | static int64_t generatetable(const char *, const char *, char **); | 16 | static int64_t generatetable(const char *, const char *, char **); |
| @@ -41,24 +41,19 @@ write_stdout(const char *str, ...) | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static double | 43 | static double |
| 44 | timerun(void (*run)(void), const char *name) | 44 | timerun(void (*run)(void)) |
| 45 | { | 45 | { |
| 46 | struct timespec start, end; | 46 | struct timespec start, end; |
| 47 | double tdiff, tdsec, tdnano; | 47 | double tdiff, tdsec, tdnano; |
| 48 | 48 | ||
| 49 | printf("\n"); | ||
| 50 | fflush(stdout); | 49 | fflush(stdout); |
| 51 | 50 | ||
| 52 | if (run == NULL) { | 51 | if (run == NULL) { |
| 53 | printf("> %s: nothing to run!\n", name); | 52 | printf("nothing to run!\n"); |
| 54 | fflush(stdout); | 53 | fflush(stdout); |
| 55 | return -1.0; | 54 | return -1.0; |
| 56 | } | 55 | } |
| 57 | 56 | ||
| 58 | printf("Running tool: %s\n", name); | ||
| 59 | printf("==========\n"); | ||
| 60 | fflush(stdout); | ||
| 61 | |||
| 62 | clock_gettime(CLOCK_MONOTONIC, &start); | 57 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 63 | run(); | 58 | run(); |
| 64 | clock_gettime(CLOCK_MONOTONIC, &end); | 59 | clock_gettime(CLOCK_MONOTONIC, &end); |
| @@ -67,7 +62,7 @@ timerun(void (*run)(void), const char *name) | |||
| 67 | tdnano = end.tv_nsec - start.tv_nsec; | 62 | tdnano = end.tv_nsec - start.tv_nsec; |
| 68 | tdiff = tdsec + 1e-9 * tdnano; | 63 | tdiff = tdsec + 1e-9 * tdnano; |
| 69 | 64 | ||
| 70 | printf("==========\n"); | 65 | printf("---------\n"); |
| 71 | printf("\nTotal time: %.4fs\n", tdiff); | 66 | printf("\nTotal time: %.4fs\n", tdiff); |
| 72 | fflush(stdout); | 67 | fflush(stdout); |
| 73 | 68 | ||
