diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2024-08-26 11:46:27 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-10-08 08:14:53 +0200 |
commit | 661841fe2fbd3cb43c15eb6f760bfbbb1883c793 (patch) | |
tree | ef72f9bdd85d1fce32aa7482e482005402d61b26 /tests/mtd-tests | |
parent | a22a7fe5636a1babcc2fa0a9b3836c3ce5f3d0fd (diff) |
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 <miquel.raynal@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/mtd-tests')
-rw-r--r-- | tests/mtd-tests/flash_speed.c | 14 |
1 files 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 */ |