#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)
byte name[files][16];
struct asio_request *req[files];
- init_timer();
+ init_timer(&timer);
io_queue.buffer_size = bufsize;
io_queue.max_writebacks = 2;
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;
#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)
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");
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;
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
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));
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;
}
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;
}
uns ks, vs, vs2, perc, cnt;
char *ch;
int dont_delete = 0;
+ timestamp_t timer;
log_init("dbtest");
setvbuf(stdout, NULL, _IONBF, 0);
while (optind < argc)
{
char *o = argv[optind++];
- init_timer();
+ init_timer(&timer);
switch (*o)
{
case 'c':
help();
}
sdbm_sync(d);
- printf("%d ms\n", get_timer());
+ printf("%d ms\n", get_timer(&timer));
}
verb("CLOSE\n");
/*** 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 ***/
/*** 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 ***/