From ccf7a2b3a211e8590f01f29f9daac49ec83308a1 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 7 Jun 2017 11:12:11 -0500 Subject: [PATCH] secp256k1: Add benchmark for field normalization. --- dcrec/secp256k1/bench_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dcrec/secp256k1/bench_test.go b/dcrec/secp256k1/bench_test.go index 0f218ca7cc..5f0fd0ea05 100644 --- a/dcrec/secp256k1/bench_test.go +++ b/dcrec/secp256k1/bench_test.go @@ -112,3 +112,13 @@ func BenchmarkSigVerify(b *testing.B) { sig.Verify(msgHash.Bytes(), &pubKey) } } + +// BenchmarkFieldNormalize benchmarks how long it takes the internal field +// to perform normalization (which includes modular reduction). +func BenchmarkFieldNormalize(b *testing.B) { + // The normalize function is constant time so default value is fine. + f := new(fieldVal) + for i := 0; i < b.N; i++ { + f.Normalize() + } +}