Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/bench.h
/********************************************************************** | /********************************************************************** | ||||
* Copyright (c) 2014 Pieter Wuille * | * Copyright (c) 2014 Pieter Wuille * | ||||
* Distributed under the MIT software license, see the accompanying * | * Distributed under the MIT software license, see the accompanying * | ||||
* file COPYING or http://www.opensource.org/licenses/mit-license.php.* | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* | ||||
**********************************************************************/ | **********************************************************************/ | ||||
#ifndef _SECP256K1_BENCH_H_ | #ifndef SECP256K1_BENCH_H | ||||
#define _SECP256K1_BENCH_H_ | #define SECP256K1_BENCH_H | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <math.h> | #include <math.h> | ||||
#include "sys/time.h" | #include "sys/time.h" | ||||
static double gettimedouble(void) { | static double gettimedouble(void) { | ||||
struct timeval tv; | struct timeval tv; | ||||
gettimeofday(&tv, NULL); | gettimeofday(&tv, NULL); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { | ||||
print_number(min * 1000000.0 / iter); | print_number(min * 1000000.0 / iter); | ||||
printf("us / avg "); | printf("us / avg "); | ||||
print_number((sum / count) * 1000000.0 / iter); | print_number((sum / count) * 1000000.0 / iter); | ||||
printf("us / max "); | printf("us / max "); | ||||
print_number(max * 1000000.0 / iter); | print_number(max * 1000000.0 / iter); | ||||
printf("us\n"); | printf("us\n"); | ||||
} | } | ||||
#endif | #endif /* SECP256K1_BENCH_H */ |