From: Martin Mares Date: Sat, 17 Feb 2007 21:03:32 +0000 (+0100) Subject: Updated all users of the timer interface to pass an explicit timer context. X-Git-Tag: holmes-import~506^2~13^2~140 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e34560a76a7af3fb428604e4da3cd14cfd1bf454;p=libucw.git Updated all users of the timer interface to pass an explicit timer context. --- diff --git a/debug/sorter/asio-test.c b/debug/sorter/asio-test.c index 974f70a1..a7c61627 100644 --- a/debug/sorter/asio-test.c +++ b/debug/sorter/asio-test.c @@ -15,14 +15,16 @@ #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(); \ + 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(); \ + 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) @@ -40,7 +42,7 @@ int main(int argc, char **argv) byte name[files][16]; struct asio_request *req[files]; - init_timer(); + init_timer(&timer); io_queue.buffer_size = bufsize; io_queue.max_writebacks = 2; @@ -79,7 +81,7 @@ int main(int argc, char **argv) die("Cannot create %s: %m", name[i]); } sync(); - get_timer(); + get_timer(&timer); log(L_INFO, "Writing %d MB to %d files in parallel with %d byte buffers", (int)(total_size >> 20), files, bufsize); P_INIT; diff --git a/debug/sorter/file-test.c b/debug/sorter/file-test.c index f861bbb5..b6915b3f 100644 --- a/debug/sorter/file-test.c +++ b/debug/sorter/file-test.c @@ -13,14 +13,16 @@ #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(); \ + 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(); \ + 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) @@ -37,7 +39,7 @@ int main(int argc, char **argv) uns xbufsize = bufsize; // Used for single-file I/O byte *xbuf = big_alloc(xbufsize); - init_timer(); + init_timer(&timer); #ifdef COPY log(L_INFO, "Creating input file"); @@ -68,7 +70,7 @@ int main(int argc, char **argv) buf[i] = big_alloc(bufsize); } sync(); - get_timer(); + get_timer(&timer); log(L_INFO, "Writing %d MB to %d files in parallel with %d byte buffers", (int)(total_size >> 20), files, bufsize); P_INIT; diff --git a/debug/sorter/retros.c b/debug/sorter/retros.c index a97e5545..2281b733 100644 --- a/debug/sorter/retros.c +++ b/debug/sorter/retros.c @@ -695,7 +695,8 @@ int main(int argc, char **argv) array0[i] = array1[i] = (struct elt) { 0 }; mk_ary(); - init_timer(); + timestamp_t timer; + init_timer(&timer); for (uns i=0; i<5; i++) { #if 1 @@ -708,9 +709,9 @@ int main(int argc, char **argv) ary[j] = alt[j]; #endif } - log(L_DEBUG, "memcpy: %d", get_timer()/10); + log(L_DEBUG, "memcpy: %d", get_timer(&timer)/10); -#define BENCH(type, name, func) mk_##type(); init_timer(); func; log(L_DEBUG, name ": %d", get_timer()); chk_##type() +#define BENCH(type, name, func) mk_##type(); init_timer(&timer); func; log(L_DEBUG, name ": %d", get_timer(&timer)); chk_##type() //BENCH(ary, "qsort", qsort(ary, n, sizeof(struct elt), comp)); //BENCH(ary, "arraysort", as_sort(n, ary)); diff --git a/images/color.c b/images/color.c index ee1525e0..b5dcaf5f 100644 --- a/images/color.c +++ b/images/color.c @@ -1256,18 +1256,19 @@ main(void) byte *a = xmalloc(3 * CNT), *b = xmalloc(3 * CNT); for (uns i = 0; i < 3 * CNT; i++) a[i] = random_max(256); - init_timer(); + timestamp_t timer; + init_timer(&timer); for (uns i = 0; i < TESTS; i++) memcpy(b, a, CNT * 3); - DBG("memcpy time=%d", (uns)get_timer()); - init_timer(); + DBG("memcpy time=%d", get_timer(&timer)); + init_timer(&timer); for (uns i = 0; i < TESTS; i++) srgb_to_luv_pixels(b, a, CNT); - DBG("direct time=%d", (uns)get_timer()); - init_timer(); + DBG("direct time=%d", get_timer(&timer)); + init_timer(&timer); for (uns i = 0; i < TESTS; i++) color_conv_pixels(b, a, CNT, srgb_to_luv_grid); - DBG("grid time=%d", (uns)get_timer()); + DBG("grid time=%d", get_timer(&timer)); #endif return 0; } diff --git a/lib/asort-test.c b/lib/asort-test.c index acc209fc..9c6abd47 100644 --- a/lib/asort-test.c +++ b/lib/asort-test.c @@ -61,15 +61,17 @@ static int qs_comp(const struct elt *X, const struct elt *Y) int main(void) { + timestamp_t timer; + generate(); - init_timer(); + init_timer(&timer); qsort(array, N, sizeof(array[0]), (int (*)(const void *, const void *)) qs_comp); - printf("qsort: %d ms\n", get_timer()); + printf("qsort: %d ms\n", get_timer(&timer)); check(); generate(); - init_timer(); + init_timer(&timer); as_sort(N); - printf("asort: %d ms\n", get_timer()); + printf("asort: %d ms\n", get_timer(&timer)); check(); return 0; } diff --git a/lib/db-test.c b/lib/db-test.c index d0f3a5eb..9a6f3bb6 100644 --- a/lib/db-test.c +++ b/lib/db-test.c @@ -262,6 +262,7 @@ int main(int argc, char **argv) uns ks, vs, vs2, perc, cnt; char *ch; int dont_delete = 0; + timestamp_t timer; log_init("dbtest"); setvbuf(stdout, NULL, _IONBF, 0); @@ -333,7 +334,7 @@ int main(int argc, char **argv) while (optind < argc) { char *o = argv[optind++]; - init_timer(); + init_timer(&timer); switch (*o) { case 'c': @@ -459,7 +460,7 @@ int main(int argc, char **argv) help(); } sdbm_sync(d); - printf("%d ms\n", get_timer()); + printf("%d ms\n", get_timer(&timer)); } verb("CLOSE\n"); diff --git a/lib/sorter/old-test.c b/lib/sorter/old-test.c index a7b6bf4f..6c31c62c 100644 --- a/lib/sorter/old-test.c +++ b/lib/sorter/old-test.c @@ -22,18 +22,20 @@ /*** Time measurement ***/ +static timestamp_t timer; + static void start(void) { sync(); - init_timer(); + init_timer(&timer); } static void stop(void) { sync(); - log(L_INFO, "Test took %.3fs", get_timer() / 1000.); + log(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.); } /*** Simple 4-byte integer keys ***/ diff --git a/lib/sorter/sort-test.c b/lib/sorter/sort-test.c index 8cf1433f..7e3bfd0d 100644 --- a/lib/sorter/sort-test.c +++ b/lib/sorter/sort-test.c @@ -22,18 +22,20 @@ /*** Time measurement ***/ +static timestamp_t timer; + static void start(void) { sync(); - init_timer(); + init_timer(&timer); } static void stop(void) { sync(); - log(L_INFO, "Test took %.3fs", get_timer() / 1000.); + log(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.); } /*** Simple 4-byte integer keys ***/