From adae13963a67d85d39ca990b262688a729a98edc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 13 Aug 2020 17:25:50 +0200 Subject: Move benchmarks to a separate directory --- test/bench.h | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 test/bench.h (limited to 'test/bench.h') diff --git a/test/bench.h b/test/bench.h deleted file mode 100644 index 716601b..0000000 --- a/test/bench.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright 2011 David Robillard - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#define _POSIX_C_SOURCE 199309L - -#include -#include - -static inline double -elapsed_s(const struct timespec* start, const struct timespec* end) -{ - return ( (double)(end->tv_sec - start->tv_sec) - + ((double)(end->tv_nsec - start->tv_nsec) * 0.000000001) ); -} - -static inline struct timespec -bench_start(void) -{ - struct timespec start_t; - clock_gettime(CLOCK_MONOTONIC, &start_t); - return start_t; -} - -static inline double -bench_end(const struct timespec* start_t) -{ - struct timespec end_t; - clock_gettime(CLOCK_MONOTONIC, &end_t); - return elapsed_s(start_t, &end_t); -} - -- cgit v1.2.1