LMMS
Loading...
Searching...
No Matches
bench.h
Go to the documentation of this file.
1/*
2 Copyright 2011-2014 David Robillard <http://drobilla.net>
3
4 Permission to use, copy, modify, and/or distribute this software for any
5 purpose with or without fee is hereby granted, provided that the above
6 copyright notice and this permission notice appear in all copies.
7
8 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
20
21#ifndef BENCH_H
22#define BENCH_H
23
24#define _POSIX_C_SOURCE 200809L
25
26#include <time.h>
27#include <sys/time.h>
28
29static inline double
30bench_elapsed_s(const struct timespec* start, const struct timespec* end)
31{
32 return ((end->tv_sec - start->tv_sec)
33 + ((end->tv_nsec - start->tv_nsec) * 0.000000001));
34}
35
36static inline struct timespec
38{
39 struct timespec start_t;
40 clock_gettime(CLOCK_REALTIME, &start_t);
41 return start_t;
42}
43
44static inline double
45bench_end(const struct timespec* start_t)
46{
47 struct timespec end_t;
48 clock_gettime(CLOCK_REALTIME, &end_t);
49 return bench_elapsed_s(start_t, &end_t);
50}
51
52#endif /* BENCH_H */
static double bench_end(const struct timespec *start_t)
Definition bench.h:45
static struct timespec bench_start(void)
Definition bench.h:37
static double bench_elapsed_s(const struct timespec *start, const struct timespec *end)
Definition bench.h:30
virtual ASIOError start()=0
#define void
Definition unzip.h:396