runners: bench: Renamed bench m -> probe

This needed a different name, and "bench probe" is sort of reminiscent
of the "debug probes" you can use to measure things in the real world.

Maybe this is just my embedded engineering background poking through,
but honestly anything is better than a single char m, especially for a
non-integer field.
This commit is contained in:
Christopher Haster
2026-01-24 05:25:31 -06:00
parent fe93d62523
commit f07ed90a63
3 changed files with 25 additions and 25 deletions
+12 -12
View File
@@ -602,7 +602,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size) {
// bench recording state // bench recording state
typedef struct bench_record { typedef struct bench_record {
const char *m; const char *probe;
lfs3_emubd_io_t last_reads; lfs3_emubd_io_t last_reads;
lfs3_emubd_io_t last_progs; lfs3_emubd_io_t last_progs;
lfs3_emubd_io_t last_erases; lfs3_emubd_io_t last_erases;
@@ -622,7 +622,7 @@ void bench_reset(struct lfs3_cfg *cfg) {
bench_record_count = 0; bench_record_count = 0;
} }
void bench_start(const char *m) { void bench_start(const char *probe) {
// measure current read/prog/erase // measure current read/prog/erase
assert(bench_cfg); assert(bench_cfg);
lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg); lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg);
@@ -646,7 +646,7 @@ void bench_start(const char *m) {
sizeof(bench_record_t), sizeof(bench_record_t),
&bench_record_count, &bench_record_count,
&bench_record_capacity); &bench_record_capacity);
record->m = m; record->probe = probe;
record->last_reads = reads; record->last_reads = reads;
record->last_progs = progs; record->last_progs = progs;
record->last_erases = erases; record->last_erases = erases;
@@ -656,7 +656,7 @@ void bench_start(const char *m) {
record->last_simtime = simtime; record->last_simtime = simtime;
} }
void bench_stop(const char *m, uintmax_t n) { void bench_stop(const char *probe, uintmax_t n) {
// measure current read/prog/erase // measure current read/prog/erase
assert(bench_cfg); assert(bench_cfg);
lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg); lfs3_emubd_sio_t reads = lfs3_emubd_reads(bench_cfg);
@@ -676,14 +676,14 @@ void bench_stop(const char *m, uintmax_t n) {
// find our record // find our record
for (size_t i = 0; i < bench_record_count; i++) { for (size_t i = 0; i < bench_record_count; i++) {
if (strcmp(bench_records[i].m, m) == 0) { if (strcmp(bench_records[i].probe, probe) == 0) {
// print results // print results
if (simtime >= 0) { if (simtime >= 0) {
printf("benched %s %jd " printf("benched %s %jd "
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64"\n", "%"PRIu64"\n",
m, probe,
n, n,
reads - bench_records[i].last_reads, reads - bench_records[i].last_reads,
progs - bench_records[i].last_progs, progs - bench_records[i].last_progs,
@@ -696,7 +696,7 @@ void bench_stop(const char *m, uintmax_t n) {
printf("benched %s %jd " printf("benched %s %jd "
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64" %"PRIu64" %"PRIu64"\n", "%"PRIu64" %"PRIu64" %"PRIu64"\n",
m, probe,
n, n,
reads - bench_records[i].last_reads, reads - bench_records[i].last_reads,
progs - bench_records[i].last_progs, progs - bench_records[i].last_progs,
@@ -717,23 +717,23 @@ void bench_stop(const char *m, uintmax_t n) {
// not found? // not found?
fprintf(stderr, "error: bench stopped before it was started (%s)\n", fprintf(stderr, "error: bench stopped before it was started (%s)\n",
m); probe);
assert(false); assert(false);
exit(-1); exit(-1);
} }
void bench_result(const char *m, uintmax_t n, uintmax_t result) { void bench_result(const char *probe, uintmax_t n, uintmax_t result) {
// we just print these directly // we just print these directly
printf("benched %s %jd %"PRIu64"\n", printf("benched %s %jd %"PRIu64"\n",
m, probe,
n, n,
result); result);
} }
void bench_fresult(const char *m, uintmax_t n, double result) { void bench_fresult(const char *probe, uintmax_t n, double result) {
// we just print these directly // we just print these directly
printf("benched %s %jd %.6f\n", printf("benched %s %jd %.6f\n",
m, probe,
n, n,
result); result);
} }
+9 -9
View File
@@ -19,20 +19,20 @@ void bench_trace(const char *fmt, ...);
#define LFS3_TRACE(...) LFS3_TRACE_(__VA_ARGS__, "") #define LFS3_TRACE(...) LFS3_TRACE_(__VA_ARGS__, "")
#define LFS3_EMUBD_TRACE(...) LFS3_TRACE_(__VA_ARGS__, "") #define LFS3_EMUBD_TRACE(...) LFS3_TRACE_(__VA_ARGS__, "")
// BENCH_START/BENCH_STOP macros measure readed/proged/erased bytes // BENCH_START/BENCH_STOP macros measure readed/progged/erased bytes
// through emubd // through emubd
void bench_start(const char *m); void bench_start(const char *probe);
void bench_stop(const char *m, uintmax_t n); void bench_stop(const char *probe, uintmax_t n);
#define BENCH_START(m) bench_start(m) #define BENCH_START(probe) bench_start(probe)
#define BENCH_STOP(m, n) bench_stop(m, n) #define BENCH_STOP(probe, n) bench_stop(probe, n)
// BENCH_RESULT/BENCH_FRESULT allow for explicit non-io measurements // BENCH_RESULT/BENCH_FRESULT allow for explicit non-io measurements
void bench_result(const char *m, uintmax_t n, uintmax_t result); void bench_result(const char *probe, uintmax_t n, uintmax_t result);
void bench_fresult(const char *m, uintmax_t n, double result); void bench_fresult(const char *probe, uintmax_t n, double result);
#define BENCH_RESULT(m, n, result) bench_result(m, n, result) #define BENCH_RESULT(probe, n, result) bench_result(probe, n, result)
#define BENCH_FRESULT(m, n, result) bench_fresult(m, n, result) #define BENCH_FRESULT(probe, n, result) bench_fresult(probe, n, result)
// note these are indirectly included in any generated files // note these are indirectly included in any generated files
+4 -4
View File
@@ -1092,7 +1092,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
'|' '(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):' '|' '(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):'
' *(?P<message>.*)' ' *(?P<message>.*)'
'|' '(?P<op__>benched)' '|' '(?P<op__>benched)'
' (?P<m>[^\s]+)' ' (?P<probe>[^\s]+)'
' (?P<n>\d+)' ' (?P<n>\d+)'
'(?:' '(?:'
'(?:' '(?:'
@@ -1185,7 +1185,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
if args.get('keep_going'): if args.get('keep_going'):
proc.kill() proc.kill()
elif op == 'benched': elif op == 'benched':
m_ = m.group('m') probe_ = m.group('probe')
n_ = int(m.group('n')) n_ = int(m.group('n'))
# parse measurements # parse measurements
def dat(v): def dat(v):
@@ -1214,7 +1214,7 @@ def run_stage(name, runner, bench_ids, stdout_, trace_, output_, **args):
'suite': last_suite, 'suite': last_suite,
'case': last_case, 'case': last_case,
**last_defines, **last_defines,
'm': m_, 'probe': probe_,
'n': n_, 'n': n_,
'bench_reads': reads_, 'bench_reads': reads_,
'bench_progs': progs_, 'bench_progs': progs_,
@@ -1401,7 +1401,7 @@ def run(runner, bench_ids=[], **args):
output = BenchOutput(args['output'], output = BenchOutput(args['output'],
['suite', 'case'], ['suite', 'case'],
# defines go here # defines go here
['m', 'n', ['probe', 'n',
'bench_reads', 'bench_reads',
'bench_progs', 'bench_progs',
'bench_erases', 'bench_erases',