MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / BenchmarkSign

Function BenchmarkSign

crypto/asymmetric/signature_test.go:205–293  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

203}
204
205func BenchmarkSign(b *testing.B) {
206 b.Run("Secp256k1", func(b *testing.B) {
207 b.Log(b.Name())
208 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
209
210 b.ReportAllocs()
211 b.ResetTimer()
212 for i := 0; i < b.N; i++ {
213 _, err := priv.Sign(hash[:])
214 if err != nil {
215 b.Fatalf("error occurred: %v", err)
216 }
217 }
218 })
219
220 b.Run("C-Secp256k1", func(b *testing.B) {
221 b.Log(b.Name())
222 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
223 _, privP := generateKeyPair()
224
225 b.ReportAllocs()
226 b.ResetTimer()
227 for i := 0; i < b.N; i++ {
228 _, err := secp256k1.Sign(hash, privP)
229 if err != nil {
230 b.Fatalf("error occurred: %v", err)
231 }
232 }
233 })
234
235 b.Run("P224", func(b *testing.B) {
236 b.Log(b.Name())
237 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
238 privP, _ := ecdsa.GenerateKey(elliptic.P224(), crand.Reader)
239
240 b.ReportAllocs()
241 b.ResetTimer()
242 for i := 0; i < b.N; i++ {
243 ecdsa.Sign(crand.Reader, privP, hash)
244 }
245 })
246
247 b.Run("P256", func(b *testing.B) {
248 b.Log(b.Name())
249 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
250 privP, _ := ecdsa.GenerateKey(elliptic.P256(), crand.Reader)
251
252 b.ReportAllocs()
253 b.ResetTimer()
254 for i := 0; i < b.N; i++ {
255 ecdsa.Sign(crand.Reader, privP, hash)
256 }
257 })
258
259 b.Run("P384", func(b *testing.B) {
260 b.Log(b.Name())
261 hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
262 privP, _ := ecdsa.GenerateKey(elliptic.P384(), crand.Reader)

Callers

nothing calls this directly

Calls 5

SignFunction · 0.92
NameMethod · 0.80
FatalfMethod · 0.80
generateKeyPairFunction · 0.70
SignMethod · 0.65

Tested by

no test coverage detected