Skip to content

Commit 76a4fc6

Browse files
committed
bench: print clock info
1 parent a1ea09a commit 76a4fc6

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
@@ -252,6 +252,7 @@ int main(int argc, char** argv) {
252252
data.pubkeylen = 33;
253253
CHECK(secp256k1_ec_pubkey_serialize(data.ctx, data.pubkey, &data.pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED) == 1);
254254

255+
print_clock_info();
255256
print_output_table_header_row();
256257
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);
257258

src/bench.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ static int get_iters(int default_iters) {
156156
}
157157
}
158158

159+
static void print_clock_info(void) {
160+
#if defined(CLOCK_PROCESS_CPUTIME_ID)
161+
printf("INFO: Using per-process CPU timer\n\n");
162+
#else
163+
printf("WARN: Using global timer instead of per-process CPU timer.\n\n");
164+
#endif
165+
}
166+
159167
static void print_output_table_header_row(void) {
160168
char* bench_str = "Benchmark"; /* left justified */
161169
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
@@ -363,6 +363,7 @@ int main(int argc, char **argv) {
363363
secp256k1_ge_set_all_gej_var(data.pubkeys, data.pubkeys_gej, POINTS);
364364

365365

366+
print_clock_info();
366367
print_output_table_header_row();
367368
/* Initialize offset1 and offset2 */
368369
hash_into_offset(&data, 0);

src/bench_internal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ int main(int argc, char **argv) {
398398
}
399399
}
400400

401+
print_clock_info();
401402
print_output_table_header_row();
402403

403404
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)