Skip to content

Commit 5fe7c01

Browse files
committed
bench: print clock info
1 parent 6ec4255 commit 5fe7c01

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/bench.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ int main(int argc, char** argv) {
254254
data.pubkeylen = 33;
255255
CHECK(secp256k1_ec_pubkey_serialize(data.ctx, data.pubkey, &data.pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
256256

257+
print_clock_info();
257258
print_output_table_header_row();
258259
if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "verify") || have_flag(argc, argv, "ecdsa_verify")) run_benchmark("ecdsa_verify", bench_verify, NULL, NULL, &data, 10, iters);
259260

src/bench.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ static int get_iters(int default_iters) {
190190
}
191191
}
192192

193+
static void print_clock_info(void) {
194+
#if defined(CLOCK_PROCESS_CPUTIME_ID)
195+
printf("INFO: Using per-process CPU timer\n\n");
196+
#else
197+
printf("WARN: Using wall-clock timer instead of per-process CPU timer.\n\n");
198+
#endif
199+
}
200+
193201
static void print_output_table_header_row(void) {
194202
char* bench_str = "Benchmark"; /* left justified */
195203
char* min_str = " Min(us) "; /* center alignment */

src/bench_ecmult.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ int main(int argc, char **argv) {
365365
}
366366
secp256k1_ge_set_all_gej_var(data.pubkeys, data.pubkeys_gej, POINTS);
367367

368+
print_clock_info();
368369
print_output_table_header_row();
369370
/* Initialize offset1 and offset2 */
370371
hash_into_offset(&data, 0);

src/bench_internal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ int main(int argc, char **argv) {
401401
}
402402
}
403403

404+
print_clock_info();
404405
print_output_table_header_row();
405406

406407
if (d || have_flag(argc, argv, "scalar") || have_flag(argc, argv, "half")) run_benchmark("scalar_half", bench_scalar_half, bench_setup, NULL, &data, 10, iters*100);

0 commit comments

Comments
 (0)