runners: bench: Moved bench n to BENCH_STOP

This was a funny issue for external benchmarking, where we've focused
mostly on throughput benchmarking so far.

The current throughput approach is to run a benchmark for a given
simtime, and record the number of bytes written after. This is great for
allowing benchmarks to fail gracefully, but doesn't really work with the
current bench runner, which expected a known n in BENCH_START.

We can work around this by calling BENCH_START/STOP a second time
(making a mess of later scripts), but it would be nice if this was fixed
in the bench runner.

---

Humorously, BENCH_START just stores n to be printed out when BENCH_STOP
is called, so this was an easy fix.
This commit is contained in:
Christopher Haster
2026-01-21 01:41:57 -06:00
parent 68de9efd17
commit 0589e75ad0
2 changed files with 10 additions and 12 deletions
+6 -8
View File
@@ -603,7 +603,6 @@ 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 *m;
uintmax_t n;
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;
@@ -623,7 +622,7 @@ void bench_reset(struct lfs3_cfg *cfg) {
bench_record_count = 0; bench_record_count = 0;
} }
void bench_start(const char *m, uintmax_t n) { void bench_start(const char *m) {
// 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);
@@ -648,7 +647,6 @@ void bench_start(const char *m, uintmax_t n) {
&bench_record_count, &bench_record_count,
&bench_record_capacity); &bench_record_capacity);
record->m = m; record->m = m;
record->n = n;
record->last_reads = reads; record->last_reads = reads;
record->last_progs = progs; record->last_progs = progs;
record->last_erases = erases; record->last_erases = erases;
@@ -658,7 +656,7 @@ void bench_start(const char *m, uintmax_t n) {
record->last_simtime = simtime; record->last_simtime = simtime;
} }
void bench_stop(const char *m) { void bench_stop(const char *m, 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);
@@ -685,8 +683,8 @@ void bench_stop(const char *m) {
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64"\n", "%"PRIu64"\n",
bench_records[i].m, m,
bench_records[i].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,
erases - bench_records[i].last_erases, erases - bench_records[i].last_erases,
@@ -698,8 +696,8 @@ void bench_stop(const char *m) {
printf("benched %s %jd " printf("benched %s %jd "
"%"PRIu64" %"PRIu64" %"PRIu64" " "%"PRIu64" %"PRIu64" %"PRIu64" "
"%"PRIu64" %"PRIu64" %"PRIu64"\n", "%"PRIu64" %"PRIu64" %"PRIu64"\n",
bench_records[i].m, m,
bench_records[i].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,
erases - bench_records[i].last_erases, erases - bench_records[i].last_erases,
+4 -4
View File
@@ -21,11 +21,11 @@ void bench_trace(const char *fmt, ...);
// BENCH_START/BENCH_STOP macros measure readed/proged/erased bytes // BENCH_START/BENCH_STOP macros measure readed/proged/erased bytes
// through emubd // through emubd
void bench_start(const char *m, uintmax_t n); void bench_start(const char *m);
void bench_stop(const char *m); void bench_stop(const char *m, uintmax_t n);
#define BENCH_START(m, n) bench_start(m, n) #define BENCH_START(m) bench_start(m)
#define BENCH_STOP(m) bench_stop(m) #define BENCH_STOP(m, n) bench_stop(m, 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 *m, uintmax_t n, uintmax_t result);