Skip to content
Snippets Groups Projects
Commit 0cf52e2f authored by Florian Fischer's avatar Florian Fischer
Browse files

make experiment size adjustable

parent c6ded6c5
No related branches found
No related tags found
1 merge request!3Work work work
Pipeline #66506 passed
......@@ -12,8 +12,8 @@
void init(int fd);
void do_write(int fd, const void *buf, size_t count);
const size_t warmup = 10000;
const size_t iterations = 1000000;
size_t warmup = 10000;
size_t iterations = 1000000;
#define BUFSIZE 64
......@@ -44,10 +44,14 @@ int main() {
int fd = create_eventfd();
init(fd);
const size_t exp_warmup = warmup;
const size_t exp_iterations = iterations;
for (size_t i = 0; i < warmup; ++i) do_write(fd, &write_buf, sizeof(write_buf));
if (exp_iterations == 0) errx(EXIT_FAILURE, "experiment must do at least one iteration");
for (int64_t i = 1; i <= iterations; ++i) {
for (size_t i = 0; i < exp_warmup; ++i) do_write(fd, &write_buf, sizeof(write_buf));
for (int64_t i = 1; i <= exp_iterations; ++i) {
do_write(fd, &write_buf, sizeof(write_buf));
if (__builtin_add_overflow(nanos_sum, clock_diff_nanos(), &nanos_sum))
errx(EXIT_FAILURE, "nanos overflowed at %ld", i);
......@@ -58,8 +62,8 @@ int main() {
// Since uint64_t <-> double conversion are not well defined
// and we use really small units (cycles and nanoseconds) I am willing
// to accept that we throw away anything after the decimal point.
uint64_t avg_nanos = nanos_sum / iterations;
uint64_t avg_cycles = cycles_sum / iterations;
uint64_t avg_nanos = nanos_sum / exp_iterations;
uint64_t avg_cycles = cycles_sum / exp_iterations;
printf("%lu ns, %lu cycles\n", avg_nanos, avg_cycles);
return 0;
......
#pragma once
#define unlikely(x) __builtin_expect(!!(x), 0)
extern size_t warmup, iterations;
......@@ -5,6 +5,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "common.h"
#include "stopwatch.h"
atomic_int done;
......@@ -19,6 +20,9 @@ void callback(union sigval sigval) {
}
void init(int fd) {
// decrease the experiment size because this takes much longer than anything else
warmup = 10;
iterations = 100;
aiocb.aio_fildes = fd;
aiocb.aio_sigevent.sigev_notify = SIGEV_THREAD;
aiocb.aio_sigevent.sigev_notify_function = callback;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment