Skip to content

Commit

Permalink
Do 3 runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Feh committed Apr 29, 2014
1 parent 816ef7e commit 8e70f0f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions write-bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ ssize_t dummy(int in, int out)

void time_run(struct bench_func *arg)
{
int i;
struct timespec start, end;
double delta;

assert(arg != NULL);

clock_gettime(CLOCK_MONOTONIC, &start);
arg->f(STDIN_FILENO, STDOUT_FILENO);
fprintf(stderr, "%-30s", arg->desc);

clock_gettime(CLOCK_MONOTONIC, &end);
for(i = 0; i < 3; i++) {
clock_gettime(CLOCK_MONOTONIC, &start);
arg->f(STDIN_FILENO, STDOUT_FILENO);
clock_gettime(CLOCK_MONOTONIC, &end);

delta = 1000 * (end.tv_sec - start.tv_sec);
delta += (end.tv_nsec - start.tv_nsec) / 100000.0;
delta = 1000 * (end.tv_sec - start.tv_sec);
delta += (end.tv_nsec - start.tv_nsec) / 100000.0;
fprintf(stderr, " % 12.2fms", delta);
}

fprintf(stdout, "%-40s %.2fms\n", arg->desc, delta);
fprintf(stderr, "\n");
}

int is_regular_file(int fd)
Expand Down

0 comments on commit 8e70f0f

Please sign in to comment.