corrected copyright notices
[gnutls.git] / src / benchmark.h
blobbcc07c7dbff05a5afe86662b53a2939f93732e98
1 /*
2 * Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 * This file is part of GnuTLS.
6 * GnuTLS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuTLS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <sys/time.h>
21 #include <time.h>
22 #include <signal.h>
23 #if defined(_WIN32)
24 # include <windows.h>
25 #endif
26 #include "timespec.h" /* gnulib gettime */
28 typedef void (*sighandler_t)(int);
30 void benchmark_cipher (int init, int debug_level);
31 void benchmark_tls (int debug_level, int ciphers);
33 struct benchmark_st
35 struct timespec start;
36 unsigned long size;
37 sighandler_t old_handler;
38 #if defined(_WIN32)
39 HANDLE wtimer;
40 HANDLE wthread;
41 LARGE_INTEGER alarm_timeout;
42 #endif
45 extern int benchmark_must_finish;
47 void start_benchmark(struct benchmark_st * st);
48 double stop_benchmark(struct benchmark_st * st, const char* metric);
50 inline static unsigned int
51 timespec_sub_ms (struct timespec *a, struct timespec *b)
53 return (a->tv_sec * 1000 + a->tv_nsec / (1000 * 1000) -
54 (b->tv_sec * 1000 + b->tv_nsec / (1000 * 1000)));