1 #include "util.h" 2 #include <poll.h> 3 #include <unistd.h> 4 #include <fcntl.h> 5 Bm_function_Poll(benchmark::State &state)6static void Bm_function_Poll(benchmark::State &state) 7 { 8 struct pollfd pfd; 9 int fd = open("/dev/zero", O_RDONLY, OPEN_MODE); 10 if (fd == -1) { 11 perror("open poll"); 12 exit(-1); 13 } 14 15 pfd.fd = fd; 16 pfd.events = POLLIN; 17 18 for (auto _ : state) { 19 benchmark::DoNotOptimize(poll(&pfd, 1, 0)); 20 } 21 22 close(fd); 23 state.SetBytesProcessed(state.iterations()); 24 } 25 26 MUSL_BENCHMARK(Bm_function_Poll);