From 9aa80af72f06dbeafdeba4540cd18f540eb808ca Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 24 Nov 2006 01:04:31 +0100 Subject: [PATCH] Improved the file benchmark slightly. --- debug/sorter/file-test.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/debug/sorter/file-test.c b/debug/sorter/file-test.c index 9ea4084c..c1672d29 100644 --- a/debug/sorter/file-test.c +++ b/debug/sorter/file-test.c @@ -3,6 +3,7 @@ */ #include "lib/lib.h" +#include "lib/lfs.h" #include #include @@ -13,8 +14,8 @@ int main(int argc, char **argv) { ASSERT(argc == 4); uns files = atol(argv[1]); - uns bufsize = atol(argv[2]); - uns rounds = atol(argv[3]); + uns bufsize = atol(argv[2]) * 1024; // Kbytes + uns rounds = (u64)atol(argv[3]) * 1024*1024 / bufsize; // Mbytes int fd[files]; byte *buf[files]; @@ -23,7 +24,7 @@ int main(int argc, char **argv) { byte name[16]; sprintf(name, "tmp/ft-%d", i); - fd[i] = open(name, O_RDWR | O_CREAT | O_TRUNC, 0666); + fd[i] = sh_open(name, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd[i] < 0) die("Cannot create %s: %m", name); buf[i] = big_alloc(bufsize); @@ -31,21 +32,32 @@ int main(int argc, char **argv) sync(); log(L_INFO, "Writing %d files in parallel with %d byte buffers", files, bufsize); + init_timer(); + u64 total = 0, total_rep = 0; for (uns r=0; r= total_rep + 1024*1024*1024) + { + printf("Wrote %d MB (round %d of %d)\r", (int)(total >> 20), r, rounds); + fflush(stdout); + total_rep = total; + } } } log(L_INFO, "Syncing"); sync(); + uns ms = get_timer(); + log(L_INFO, "Spent %dms (%d MB/sec)", ms, (uns)(total/ms*1000/1048576)); log(L_INFO, "Reading the files sequentially"); + total = total_rep = 0; for (uns i=0; i= total_rep + 1024*1024*1024) + { + printf("Read %d MB (file %d)\r", (int)(total >> 20), i); + fflush(stdout); + total_rep = total; + } } close(fd[i]); } + ms = get_timer(); + log(L_INFO, "Spent %dms (%d MB/sec)", ms, (uns)(total/ms*1000/1048576)); log(L_INFO, "Done"); return 0; -- 2.39.2