aboutsummaryrefslogtreecommitdiff
path: root/tools/tool.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-04 08:58:47 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-04 08:58:47 +0200
commit32009294d2de3e197c8d4dc950559ff948ea2fc9 (patch)
treeac297be7b6e218ee8ae21367c94c8b65297fe2ca /tools/tool.h
parent757a732336ee5f0f4b0ba44ac138210c2c1ef805 (diff)
downloadnissy-core-32009294d2de3e197c8d4dc950559ff948ea2fc9.tar.gz
nissy-core-32009294d2de3e197c8d4dc950559ff948ea2fc9.zip
Clean up tool output
Diffstat (limited to 'tools/tool.h')
-rw-r--r--tools/tool.h13
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
11static void log_stderr(const char *, ...); 11static void log_stderr(const char *, ...);
12static void log_stdout(const char *, ...); 12static void log_stdout(const char *, ...);
13static double timerun(void (*)(void), const char *); 13static double timerun(void (*)(void));
14static void getfilename(const char *, const char *, char *); 14static void getfilename(const char *, const char *, char *);
15static void writetable(const char *, int64_t, const char *); 15static void writetable(const char *, int64_t, const char *);
16static int64_t generatetable(const char *, const char *, char **); 16static int64_t generatetable(const char *, const char *, char **);
@@ -41,24 +41,19 @@ write_stdout(const char *str, ...)
41} 41}
42 42
43static double 43static double
44timerun(void (*run)(void), const char *name) 44timerun(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

Generated with cgit - Back to sebastiano.tronto.net