commtechs bench: time per loop + time per write

This commit is contained in:
Thomas Preud'homme 2009-06-24 18:18:05 +02:00 committed by Thomas Preud'homme
parent 7177f1c84d
commit e9dc20ecd8
1 changed files with 12 additions and 5 deletions

View File

@ -21,6 +21,10 @@
#define toString(x) doStringification(x)
#define doStringification(x) #x
#define INIT_CALC_ARG 16
#define WORDS_PER_BUF (BUF_SIZE / sizeof(uintptr_t))
#define DIV_SEC(secs, div) ((unsigned ) (((unsigned) secs) / (unsigned long) (div)))
#define DIV_USEC(nsecs, nusecs, div) ((unsigned) (((unsigned) (nusecs) + 1000000 * \
((unsigned ) (nsecs) % (div))) / (unsigned long) (div)))
static long nb_bufs_sent = 0;
@ -215,10 +219,10 @@ void *producer(void *unused)
{
for(i = 0; i < nb_bufs_sent; i++) {
//printf("[%p] Send %d new CACHE_LINE\n", (void *) pthread_self(), BUF_SIZE / CACHE_LINE_SIZE);
for(j = 0; j < (BUF_SIZE / sizeof(uintptr_t)); j++)
for(j = 0; j < WORDS_PER_BUF; j++)
send(do_calc());
}
print_results(BUF_SIZE / sizeof(uintptr_t), nb_bufs_sent);
print_results(WORDS_PER_BUF, nb_bufs_sent);
}
gettimeofday(&tv2, NULL);
tv_result.tv_sec = tv2.tv_sec - tv1.tv_sec;
@ -229,9 +233,12 @@ void *producer(void *unused)
}
else
tv_result.tv_usec = tv2.tv_usec - tv1.tv_usec;
printf("total_time: %u.%06u / %u.%06u / %u.%06u\n", (unsigned) tv_result.tv_sec, (unsigned) tv_result.tv_usec,
(unsigned) tv_result.tv_sec, (unsigned) tv_result.tv_usec, (unsigned) tv_result.tv_sec,
(unsigned) tv_result.tv_usec);
printf("total_time: %u.%06u / %u.%06u / %u.%06u\n", (unsigned) tv_result.tv_sec,
(unsigned) tv_result.tv_usec,
DIV_SEC(tv_result.tv_sec, nb_bufs_sent),
DIV_USEC(tv_result.tv_sec, tv_result.tv_usec, nb_bufs_sent),
DIV_SEC(tv_result.tv_sec, nb_bufs_sent * WORDS_PER_BUF),
DIV_USEC(tv_result.tv_sec, tv_result.tv_usec, nb_bufs_sent * WORDS_PER_BUF));
end_calc();
printf("[%p] Producer finished !\n", (void*) pthread_self());
/*