From 2f1f4e4ba3c0d79befb519ee37633e98d3205d94 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 8 Apr 2020 14:57:36 -0500 Subject: [PATCH] secp256k1: Add compressed pubkey parse benchmark. --- dcrec/secp256k1/bench_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dcrec/secp256k1/bench_test.go b/dcrec/secp256k1/bench_test.go index 32d50825..5e9c27a9 100644 --- a/dcrec/secp256k1/bench_test.go +++ b/dcrec/secp256k1/bench_test.go @@ -115,3 +115,17 @@ func BenchmarkPubKeyDecompress(b *testing.B) { _ = DecompressY(pubKeyX, false, &y) } } + +// BenchmarkParsePubKeyCompressed benchmarks how long it takes to parse a +// compressed public key with an even y coordinate. +func BenchmarkParsePubKeyCompressed(b *testing.B) { + format := "02" + x := "ce0b14fb842b1ba549fdd675c98075f12e9c510f8ef52bd021a9a1f4809d3b4d" + pubKeyBytes := hexToBytes(format + x) + + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + ParsePubKey(pubKeyBytes) + } +}