7#ifndef SECP256K1_BENCH_H
8#define SECP256K1_BENCH_H
17 gettimeofday(&tv, NULL);
18 return (int64_t)tv.tv_usec + (int64_t)tv.tv_sec * 1000000LL;
22#define FP_MULT (1000000LL)
36 x_abs = x < 0 ? -x : x;
50 for (i = c; i <
FP_EXP; ++i) {
51 rounding = (y % 10) >= 5;
57 ptr =
sizeof(buffer) - 1;
60 for (i = 0; i < c; ++i) {
61 buffer[--ptr] =
'0' + (y % 10);
67 buffer[--ptr] =
'0' + (y % 10);
73 printf(
"%s", &buffer[ptr]);
78 int64_t min = INT64_MAX;
81 for (i = 0; i <
count; i++) {
89 if (teardown != NULL) {
110 char** argm = argv + argc;
115 while (argv != NULL && argv != argm) {
116 if (strcmp(*argv, flag) == 0) {
125 char* env = getenv(
"SECP256K1_BENCH_ITERS");
127 return strtol(env, NULL, 0);
129 return default_iters;
int have_flag(int argc, char **argv, char *flag)
int get_iters(int default_iters)
void print_number(const int64_t x)
static int64_t gettime_i64(void)
void run_benchmark(char *name, void(*benchmark)(void *, int), void(*setup)(void *), void(*teardown)(void *, int), void *data, int count, int iter)