History

checkasm: add csv/tsv bench output

When collecting performance information from checkasm it is common to parse the output for use in graphs to compare vs different architectures.

J. Dekker committed 2 years ago

Commit 42528ff1 parent d89930f1 file · +20 −2Browse files

Unified · Split

tests/checkasm/checkasm.c+20−2
@@ -366,6 +366,8 @@ static struct { · 365 unmodified lines
366366 const char *cpu_flag_name;
367367 const char *test_name;
368368 int verbose;
369+ int csv;
370+ int tsv;
369371 volatile sig_atomic_t catch_signals;
370372 } state;
371373
@@ -590,7 +592,14 @@ static void print_benchs(CheckasmFunc *f) · 218 unmodified lines
590592 CheckasmPerf *p = &v->perf;
591593 if (p->iterations) {
592594 int decicycles = (10*p->cycles/p->iterations - state.nop_time) / 4;
593− printf("%s_%s: %d.%d\n", f->name, cpu_suffix(v->cpu), decicycles/10, decicycles%10);
595+ if (state.csv || state.tsv) {
596+ const char sep = state.csv ? ',' : '\t';
597+ printf("%s%c%s%c%d.%d\n", f->name, sep,
598+ cpu_suffix(v->cpu), sep,
599+ decicycles / 10, decicycles % 10);
600+ } else {
601+ printf("%s_%s: %d.%d\n", f->name, cpu_suffix(v->cpu), decicycles/10, decicycles%10);
602+ }
594603 }
595604 } while ((v = v->next));
596605 }
@@ -833,7 +842,12 @@ static void bench_uninit(void) · 236 unmodified lines
833842 static int usage(const char *path)
834843 {
835844 fprintf(stderr,
836− "Usage: %s [--bench] [--runs=<ptwo>] [--test=<pattern>] [--verbose] [seed]\n",
845+ "Usage: %s [options...] [seed]\n"
846+ " --test=<pattern> Run specific test.\n"
847+ " --bench Run benchmark.\n"
848+ " --csv, --tsv Output results in rows of comma or tab separated values.\n"
849+ " --runs=<ptwo> Manual number of benchmark iterations to run 2**<ptwo>.\n"
850+ " --verbose Increase verbosity.\n",
837851 path);
838852 return 1;
839853 }
@@ -881,6 +895,10 @@ int main(int argc, char *argv[]) · 41 unmodified lines
881895 state.bench_pattern = "";
882896 } else if (!strncmp(arg, "--test=", 7)) {
883897 state.test_name = arg + 7;
898+ } else if (!strcmp(arg, "--csv")) {
899+ state.csv = 1; state.tsv = 0;
900+ } else if (!strcmp(arg, "--tsv")) {
901+ state.csv = 0; state.tsv = 1;
884902 } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
885903 state.verbose = 1;
886904 } else if (!strncmp(arg, "--runs=", 7)) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t