commit 32009294d2de3e197c8d4dc950559ff948ea2fc9
parent 757a732336ee5f0f4b0ba44ac138210c2c1ef805
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Fri, 4 Oct 2024 08:58:47 +0200
Clean up tool output
Diffstat:
7 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c
@@ -32,7 +32,6 @@ gendata_run_finish:
int main(int argc, char **argv) {
uint8_t h, k;
- char description[256];
if (argc < 3) {
fprintf(stderr, "Error: not enough arguments. "
@@ -44,12 +43,10 @@ int main(int argc, char **argv) {
options = argv[2];
parse_h48_options(options, &h, &k, NULL);
expected = expected_h48[h][k];
- sprintf(description, "benchmark gendata_h48 h = %" PRIu8
- ", k = %" PRIu8 "", h, k);
nissy_setlogger(log_stderr);
- timerun(run, description);
+ timerun(run);
return 0;
}
diff --git a/tools/001_derive_h48/derive_h48.c b/tools/001_derive_h48/derive_h48.c
@@ -7,8 +7,6 @@ void run(void) {
}
int main(int argc, char **argv) {
- char description[256];
-
if (argc < 5) {
fprintf(stderr,
"Error: not enough arguments. Required:\n"
@@ -23,11 +21,10 @@ int main(int argc, char **argv) {
opts_small = argv[2];
filename_large = argv[3];
filename_small = argv[4];
- sprintf(description, "deriving %s from %s\n", opts_small, opts_large);
nissy_setlogger(log_stderr);
- timerun(run, description);
+ timerun(run);
return 0;
}
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c
@@ -31,8 +31,6 @@ run(void) {
}
int main(int argc, char **argv) {
- char description[256];
-
if (argc < 4) {
fprintf(stderr, "Error: not enough arguments. "
"A solver, its options and a file name must be given.\n");
@@ -42,11 +40,9 @@ int main(int argc, char **argv) {
solver = argv[1];
options = argv[2];
filename = argv[3];
- sprintf(description, "checking data for solver %s"
- "with options %s from file %s", solver, options, filename);
nissy_setlogger(log_stderr);
- timerun(run, description);
+ timerun(run);
return 0;
}
diff --git a/tools/200_stats_tables_h48/stats_tables_h48.c b/tools/200_stats_tables_h48/stats_tables_h48.c
@@ -92,7 +92,7 @@ int main(void) {
if (getdata(solver, options, &buf, filename) != 0)
return 1;
- timerun(run, "h48 table stats");
+ timerun(run);
free(buf);
return 0;
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c
@@ -39,14 +39,13 @@ void run(void) {
}
int main(void) {
-
srand(time(NULL));
nissy_setlogger(log_stderr);
if (getdata(solver, options, &buf, filename) != 0)
return 1;
- timerun(run, "small solver benchmark");
+ timerun(run);
free(buf);
return 0;
diff --git a/tools/tool.h b/tools/tool.h
@@ -10,7 +10,7 @@
static void log_stderr(const char *, ...);
static void log_stdout(const char *, ...);
-static double timerun(void (*)(void), const char *);
+static double timerun(void (*)(void));
static void getfilename(const char *, const char *, char *);
static void writetable(const char *, int64_t, const char *);
static int64_t generatetable(const char *, const char *, char **);
@@ -41,24 +41,19 @@ write_stdout(const char *str, ...)
}
static double
-timerun(void (*run)(void), const char *name)
+timerun(void (*run)(void))
{
struct timespec start, end;
double tdiff, tdsec, tdnano;
- printf("\n");
fflush(stdout);
if (run == NULL) {
- printf("> %s: nothing to run!\n", name);
+ printf("nothing to run!\n");
fflush(stdout);
return -1.0;
}
- printf("Running tool: %s\n", name);
- printf("==========\n");
- fflush(stdout);
-
clock_gettime(CLOCK_MONOTONIC, &start);
run();
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -67,7 +62,7 @@ timerun(void (*run)(void), const char *name)
tdnano = end.tv_nsec - start.tv_nsec;
tdiff = tdsec + 1e-9 * tdnano;
- printf("==========\n");
+ printf("---------\n");
printf("\nTotal time: %.4fs\n", tdiff);
fflush(stdout);
diff --git a/tools/tool.sh b/tools/tool.sh
@@ -8,15 +8,36 @@ fi
CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer
BIN="tools/run"
-d="$(date +'%Y-%m-%d-%H-%M-%S')"
+RESULTS="tools/results"
+LAST="$RESULTS/last.out"
+date="$(date +'%Y-%m-%d-%H-%M-%S')"
for t in tools/*; do
if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then
continue
fi
toolname="$(basename "$t" .c)"
- $CC -o $BIN "$t"/*.c "$OBJ" || exit 1;
- $BIN $TOOLARGS \
- | tee "tools/results/$toolname-$d.txt" "tools/results/last.out"
break
done
+
+file="$RESULTS/$toolname-$date.txt"
+
+$CC -o $BIN "$t"/*.c "$OBJ" || exit 1;
+
+(
+date +'%Y-%m-%d %H:%M'
+echo ""
+echo "======== config.mk ========"
+cat config.mk
+echo "==========================="
+echo ""
+echo "=== tool configuration ===="
+echo "TOOL=$toolname"
+echo "TOOLARGS=$TOOLARGS"
+echo "CC=$CC"
+echo "==========================="
+echo ""
+echo "======= tool output ======="
+$BIN $TOOLARGS
+echo "==========================="
+) | tee "$file" "$LAST"