From 661841fe2fbd3cb43c15eb6f760bfbbb1883c793 Mon Sep 17 00:00:00 2001 From: Miquel Raynal Date: Mon, 26 Aug 2024 11:46:27 +0200 Subject: mtd-tests: flash_speed: Generalize read_eraseblock_by_2pages() Right now there are only 2 pages that may be read continuously, but why not trying more? At least when the continuous feature is out, this type of benchmarking will be interesting. In order to facilitate later additions, lets make this helper more generic and accept a global 'npages' variable as parameter (because this function is called in a macro, it is simpler like that). Signed-off-by: Miquel Raynal Signed-off-by: David Oberhollenzer --- tests/mtd-tests/flash_speed.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/mtd-tests/flash_speed.c b/tests/mtd-tests/flash_speed.c index f161d6e..6df0568 100644 --- a/tests/mtd-tests/flash_speed.c +++ b/tests/mtd-tests/flash_speed.c @@ -47,6 +47,7 @@ static const char *mtddev; static libmtd_t mtd_desc; static int fd; +static int npages = 1; static int peb=-1, count=-1, skip=-1, flags=0, speb=-1; static struct timespec start, finish; static int pgsize, pgcnt; @@ -250,17 +251,17 @@ static int read_eraseblock_by_page(int ebnum) return err; } -static int read_eraseblock_by_2pages(int ebnum) +static int read_eraseblock_by_npages(int ebnum) { - int i, n = pgcnt / 2, err = 0; - size_t sz = pgsize * 2; + int i, n = pgcnt / npages, err = 0; + size_t sz = pgsize * npages; void *buf = iobuf; for (i = 0; i < n; ++i) { err = mtd_read(&mtd, fd, ebnum, i * sz, iobuf, sz); if (err) { - fprintf(stderr, "Error reading block %d, page %d + %d!\n", - ebnum, i*2, i*2+1); + fprintf(stderr, "Error reading block %d, page [%d-%d]!\n", + ebnum, i*npages, (i*npages) + npages- 1); return err; } buf += sz; @@ -469,7 +470,8 @@ int main(int argc, char **argv) /* Read all eraseblocks, 2 pages at a time */ puts("testing 2 page read speed"); - TIME_OP_PER_PEB(read_eraseblock_by_2pages, 2); + npages = 2; + TIME_OP_PER_PEB(read_eraseblock_by_npages, npages); printf("2 page read speed is %ld KiB/s\n", speed); /* Erase all eraseblocks */ -- cgit v1.2.3