]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-tests: flash_speed: Generalize read_eraseblock_by_2pages()
authorMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 26 Aug 2024 09:46:27 +0000 (11:46 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Tue, 8 Oct 2024 06:14:53 +0000 (08:14 +0200)
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>
tests/mtd-tests/flash_speed.c

index f161d6e3dffda34e2852033880990cbf7163ec34..6df056856d793d460005fb26b6b1fd58cb63e044 100644 (file)
@@ -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 */