X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=debug%2Fsorter%2Ffile-test.c;h=b6915b3fce9a93c230468bc8c026c67fb0c0e332;hb=f3625d622964cf99300ceb7e499b99ebbce9fe69;hp=9ea4084ca3ac061f6605bf11f7e47f9fb5911c54;hpb=29e5a2ee946cfdc84e82159281b37b7b29665234;p=libucw.git diff --git a/debug/sorter/file-test.c b/debug/sorter/file-test.c index 9ea4084c..b6915b3f 100644 --- a/debug/sorter/file-test.c +++ b/debug/sorter/file-test.c @@ -3,60 +3,120 @@ */ #include "lib/lib.h" +#include "lib/lfs.h" #include #include #include #include +#define COPY +#define DIRECT O_DIRECT + +static timestamp_t timer; + +#define P_INIT do { cnt = 0; cnt_rep = 0; cnt_ms = 1; } while(0) +#define P_UPDATE(cc) do { \ + cnt += cc; \ + if (cnt >= cnt_rep) { cnt_ms += get_timer(&timer); \ + printf("%d of %d MB (%.2f MB/sec)\r", (int)(cnt >> 20), (int)(total_size >> 20), (double)cnt / 1048576 * 1000 / cnt_ms); \ + fflush(stdout); cnt_rep += 1<<26; } } while(0) +#define P_FINAL do { \ + cnt_ms += get_timer(&timer); \ + log(L_INFO, "Spent %.3f sec (%.2f MB/sec)", (double)cnt_ms/1000, (double)cnt / 1048576 * 1000 / cnt_ms); \ +} while(0) + 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 + u64 total_size = (u64)atol(argv[3]) * 1024*1024*1024; // Gbytes + u64 cnt, cnt_rep; + uns cnt_ms; int fd[files]; - byte *buf[files]; + byte *buf[files], name[files][16]; + uns xbufsize = bufsize; // Used for single-file I/O + byte *xbuf = big_alloc(xbufsize); + + init_timer(&timer); + +#ifdef COPY + log(L_INFO, "Creating input file"); + int in_fd = sh_open("tmp/ft-in", O_RDWR | O_CREAT | O_TRUNC | DIRECT, 0666); + ASSERT(in_fd >= 0); + ASSERT(!(total_size % xbufsize)); + P_INIT; + for (uns i=0; i> 20), files, bufsize); + P_INIT; + for (uns r=0; r