bench: Tweaked bench.py to include cumulative measurements

This was the one piece needed to be able to replace amor.py with csv.py.
The missing feature in csv.py is the ability to keep track of a
running-sum, but this is a bit of a hack in amor.py considering we
otherwise view csv entries as unordered.

We could add a running-sum to csv.py, or instead, just include a running
sum as a part of our bench output. We have all the information there
anyways, and if it simplifies the mess that is our csv scripts, that's a
win.

---

This also replaces the bench "meas", "iter", and "size" fields with the
slightly simpler "m" (measurement? metric?) and "n" fields. It's up to
the specific benchmark exactly how to interpret "n", but one field is
sufficient for existing scripts.
This commit is contained in:
Christopher Haster
2024-11-13 15:22:09 -06:00
parent 8911d44073
commit f385f8f778
3 changed files with 56 additions and 59 deletions
+19 -26
View File
@@ -605,9 +605,8 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size) {
// bench recording state
typedef struct bench_record {
const char *meas;
uintmax_t iter;
uintmax_t size;
const char *m;
uintmax_t n;
lfs_emubd_io_t last_readed;
lfs_emubd_io_t last_proged;
lfs_emubd_io_t last_erased;
@@ -623,7 +622,7 @@ void bench_reset(struct lfs_config *cfg) {
bench_record_count = 0;
}
void bench_start(const char *meas, uintmax_t iter, uintmax_t size) {
void bench_start(const char *m, uintmax_t n) {
// measure current read/prog/erase
assert(bench_cfg);
lfs_emubd_sio_t readed = lfs_emubd_readed(bench_cfg);
@@ -639,15 +638,14 @@ void bench_start(const char *meas, uintmax_t iter, uintmax_t size) {
sizeof(bench_record_t),
&bench_record_count,
&bench_record_capacity);
record->meas = meas;
record->iter = iter;
record->size = size;
record->m = m;
record->n = n;
record->last_readed = readed;
record->last_proged = proged;
record->last_erased = erased;
}
void bench_stop(const char *meas) {
void bench_stop(const char *m) {
// measure current read/prog/erase
assert(bench_cfg);
lfs_emubd_sio_t readed = lfs_emubd_readed(bench_cfg);
@@ -659,12 +657,11 @@ void bench_stop(const char *meas) {
// find our record
for (size_t i = 0; i < bench_record_count; i++) {
if (strcmp(bench_records[i].meas, meas) == 0) {
if (strcmp(bench_records[i].m, m) == 0) {
// print results
printf("benched %s %zd %zd %"PRIu64" %"PRIu64" %"PRIu64"\n",
bench_records[i].meas,
bench_records[i].iter,
bench_records[i].size,
printf("benched %s %zd %"PRIu64" %"PRIu64" %"PRIu64"\n",
bench_records[i].m,
bench_records[i].n,
readed - bench_records[i].last_readed,
proged - bench_records[i].last_proged,
erased - bench_records[i].last_erased);
@@ -680,28 +677,24 @@ void bench_stop(const char *meas) {
// not found?
fprintf(stderr, "error: bench stopped before it was started (%s)\n",
meas);
m);
assert(false);
exit(-1);
}
void bench_result(const char *meas, uintmax_t iter, uintmax_t size,
uintmax_t result) {
void bench_result(const char *m, uintmax_t n, uintmax_t result) {
// we just print these directly
printf("benched %s %zd %zd %"PRIu64"\n",
meas,
iter,
size,
printf("benched %s %zd %"PRIu64"\n",
m,
n,
result);
}
void bench_fresult(const char *meas, uintmax_t iter, uintmax_t size,
double result) {
void bench_fresult(const char *m, uintmax_t n, double result) {
// we just print these directly
printf("benched %s %zd %zd %.6f\n",
meas,
iter,
size,
printf("benched %s %zd %.6f\n",
m,
n,
result);
}
+8 -14
View File
@@ -21,24 +21,18 @@ void bench_trace(const char *fmt, ...);
// BENCH_START/BENCH_STOP macros measure readed/proged/erased bytes
// through emubd
void bench_start(const char *meas, uintmax_t iter, uintmax_t size);
void bench_stop(const char *meas);
void bench_start(const char *m, uintmax_t n);
void bench_stop(const char *m);
#define BENCH_START(meas, iter, size) \
bench_start(meas, iter, size)
#define BENCH_STOP(meas) \
bench_stop(meas)
#define BENCH_START(m, n) bench_start(m, n)
#define BENCH_STOP(m) bench_stop(m)
// BENCH_RESULT/BENCH_FRESULT allow for explicit non-io measurements
void bench_result(const char *meas, uintmax_t iter, uintmax_t size,
uintmax_t result);
void bench_fresult(const char *meas, uintmax_t iter, uintmax_t size,
double result);
void bench_result(const char *m, uintmax_t n, uintmax_t result);
void bench_fresult(const char *m, uintmax_t n, double result);
#define BENCH_RESULT(meas, iter, size, result) \
bench_result(meas, iter, size, result)
#define BENCH_FRESULT(meas, iter, size, result) \
bench_fresult(meas, iter, size, result)
#define BENCH_RESULT(m, n, result) bench_result(m, n, result)
#define BENCH_FRESULT(m, n, result) bench_fresult(m, n, result)
// note these are indirectly included in any generated files