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

run make format

parent 1493e990
No related branches found
No related tags found
1 merge request!2work work work
Pipeline #66438 failed
...@@ -13,8 +13,7 @@ atomic_int done; ...@@ -13,8 +13,7 @@ atomic_int done;
void callback(int sig, siginfo_t *info, void *context) { void callback(int sig, siginfo_t *info, void *context) {
stop_watch(); stop_watch();
if (info->si_value.sival_int != 42) if (info->si_value.sival_int != 42) errx(EXIT_FAILURE, "got unexpected sigval value");
errx(EXIT_FAILURE, "got unexpected sigval value");
atomic_store(&done, 1); atomic_store(&done, 1);
} }
...@@ -29,8 +28,7 @@ void init(int fd) { ...@@ -29,8 +28,7 @@ void init(int fd) {
sa.sa_sigaction = callback; sa.sa_sigaction = callback;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO; sa.sa_flags = SA_SIGINFO;
if (sigaction(SIGUSR1, &sa, NULL) == -1) if (sigaction(SIGUSR1, &sa, NULL) == -1) err(EXIT_FAILURE, "sigaction failed");
err(EXIT_FAILURE, "sigaction failed");
} }
void do_write(int fd, const void *buf, size_t count) { void do_write(int fd, const void *buf, size_t count) {
...@@ -40,10 +38,9 @@ void do_write(int fd, const void* buf, size_t count) { ...@@ -40,10 +38,9 @@ void do_write(int fd, const void* buf, size_t count) {
start_watch(); start_watch();
int res = aio_write(&aiocb); int res = aio_write(&aiocb);
if (res == -1) if (res == -1) err(EXIT_FAILURE, "aio_write failed");
err(EXIT_FAILURE, "aio_write failed");
while(!atomic_load(&done)) {} while (!atomic_load(&done)) {
}
atomic_store(&done, 1); atomic_store(&done, 1);
} }
...@@ -13,8 +13,7 @@ struct aiocb aiocb; ...@@ -13,8 +13,7 @@ struct aiocb aiocb;
void callback(union sigval sigval) { void callback(union sigval sigval) {
stop_watch(); stop_watch();
if (sigval.sival_int != 42) if (sigval.sival_int != 42) errx(EXIT_FAILURE, "got unexpected sigval value");
errx(EXIT_FAILURE, "got unexpected sigval value");
atomic_store(&done, 1); atomic_store(&done, 1);
} }
...@@ -33,9 +32,9 @@ void do_write(int fd, void* buf, size_t count) { ...@@ -33,9 +32,9 @@ void do_write(int fd, void* buf, size_t count) {
start_watch(); start_watch();
int res = aio_write(&aiocb); int res = aio_write(&aiocb);
while(!atomic_load(&done)) {} while (!atomic_load(&done)) {
}
atomic_store(&done, 0); atomic_store(&done, 0);
if (res == -1) if (res == -1) err(EXIT_FAILURE, "aio_write failed");
err(EXIT_FAILURE, "aio_write failed");
} }
...@@ -31,8 +31,7 @@ int main() { ...@@ -31,8 +31,7 @@ int main() {
init(fd); init(fd);
for (size_t i = 0; i < warmup; ++i) for (size_t i = 0; i < warmup; ++i) do_write(fd, &write_buf, sizeof(write_buf));
do_write(fd, &write_buf, sizeof(write_buf));
for (int64_t i = 1; i <= iterations; ++i) { for (int64_t i = 1; i <= iterations; ++i) {
do_write(fd, &write_buf, sizeof(write_buf)); do_write(fd, &write_buf, sizeof(write_buf));
......
...@@ -11,6 +11,5 @@ void do_write(int fd, const void* buf, size_t count) { ...@@ -11,6 +11,5 @@ void do_write(int fd, const void* buf, size_t count) {
ssize_t res = write(fd, buf, count); ssize_t res = write(fd, buf, count);
stop_watch(); stop_watch();
if (res == -1) if (res == -1) err(EXIT_FAILURE, "write failed");
err(EXIT_FAILURE, "write failed");
} }
...@@ -10,15 +10,12 @@ int nfds, epollfd; ...@@ -10,15 +10,12 @@ int nfds, epollfd;
void init(int fd) { void init(int fd) {
epollfd = epoll_create1(0); epollfd = epoll_create1(0);
if (epollfd == -1) if (epollfd == -1) err(EXIT_FAILURE, "creating epoll failed");
err(EXIT_FAILURE, "creating epoll failed");
ev.events = EPOLLOUT; ev.events = EPOLLOUT;
ev.data.fd = fd; ev.data.fd = fd;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) err(EXIT_FAILURE, "epoll_ctl failed");
err(EXIT_FAILURE, "epoll_ctl failed");
} }
void do_write(int fd, const void *buf, size_t count) { void do_write(int fd, const void *buf, size_t count) {
...@@ -27,12 +24,9 @@ void do_write(int fd, const void* buf, size_t count) { ...@@ -27,12 +24,9 @@ void do_write(int fd, const void* buf, size_t count) {
size_t res = write(fd, buf, count); size_t res = write(fd, buf, count);
stop_watch(); stop_watch();
if (nfds == -1) if (nfds == -1) err(EXIT_FAILURE, "epoll_wait failed");
err(EXIT_FAILURE, "epoll_wait failed");
if (ev.data.fd != fd) if (ev.data.fd != fd) errx(EXIT_FAILURE, "got unexpected fd from epoll");
errx(EXIT_FAILURE, "got unexpected fd from epoll");
if (res == -1) if (res == -1) err(EXIT_FAILURE, "write failed");
err(EXIT_FAILURE, "write failed");
} }
...@@ -28,7 +28,8 @@ void do_write(int fd, const void* buf, size_t count) { ...@@ -28,7 +28,8 @@ void do_write(int fd, const void* buf, size_t count) {
int res = io_uring_submit(&ring); int res = io_uring_submit(&ring);
struct io_uring_cqe *cqe; struct io_uring_cqe *cqe;
while (io_uring_peek_cqe(&ring, &cqe) == -EAGAIN) {} while (io_uring_peek_cqe(&ring, &cqe) == -EAGAIN) {
}
stop_watch(); stop_watch();
......
...@@ -25,14 +25,11 @@ void do_write(int fd, const void* buf, size_t count) { ...@@ -25,14 +25,11 @@ void do_write(int fd, const void* buf, size_t count) {
stop_watch(); stop_watch();
if (res < 0) if (res < 0) err(EXIT_FAILURE, "io_uring_submit_and_wait failed");
err(EXIT_FAILURE, "io_uring_submit_and_wait failed");
struct io_uring_cqe *cqe; struct io_uring_cqe *cqe;
res = io_uring_peek_cqe(&ring, &cqe); res = io_uring_peek_cqe(&ring, &cqe);
if (res < 0) if (res < 0) err(EXIT_FAILURE, "io_uring_peek_cqe failed");
err(EXIT_FAILURE, "io_uring_peek_cqe failed");
if (cqe->res < 0) if (cqe->res < 0) err(EXIT_FAILURE, "write request failed");
err(EXIT_FAILURE, "write request failed");
} }
...@@ -2,17 +2,12 @@ ...@@ -2,17 +2,12 @@
struct timespec start, stop; struct timespec start, stop;
int64_t sec_to_nanos(int64_t sec) { int64_t sec_to_nanos(int64_t sec) { return sec * 1000 * 1000 * 1000; }
return sec * 1000 * 1000 * 1000;
}
double nanos_to_millis(int64_t nanos) { double nanos_to_millis(int64_t nanos) { return ((double)nanos) / (1000 * 1000); }
return ((double)nanos) / (1000 * 1000);
}
int64_t clock_diff_nanos() { int64_t clock_diff_nanos() {
int64_t nanos = sec_to_nanos(stop.tv_sec - start.tv_sec); int64_t nanos = sec_to_nanos(stop.tv_sec - start.tv_sec);
nanos += (stop.tv_nsec - start.tv_nsec); nanos += (stop.tv_nsec - start.tv_nsec);
return nanos; return nanos;
} }
...@@ -5,13 +5,9 @@ ...@@ -5,13 +5,9 @@
extern struct timespec start, stop; extern struct timespec start, stop;
static inline void start_watch() { static inline void start_watch() { clock_gettime(CLOCK_MONOTONIC, &start); }
clock_gettime(CLOCK_MONOTONIC, &start);
}
static inline void stop_watch() { static inline void stop_watch() { clock_gettime(CLOCK_MONOTONIC, &stop); }
clock_gettime(CLOCK_MONOTONIC, &stop);
}
int64_t clock_diff_nanos(); int64_t clock_diff_nanos();
double nanos_to_millis(int64_t nanos); double nanos_to_millis(int64_t nanos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment