1
2
3
4
5 package fiat_test
6
7 import (
8 "crypto/elliptic/internal/fiat"
9 "testing"
10 )
11
12 func BenchmarkMul(b *testing.B) {
13 b.Run("P224", func(b *testing.B) {
14 v := new(fiat.P224Element).One()
15 b.ReportAllocs()
16 b.ResetTimer()
17 for i := 0; i < b.N; i++ {
18 v.Mul(v, v)
19 }
20 })
21 b.Run("P384", func(b *testing.B) {
22 v := new(fiat.P384Element).One()
23 b.ReportAllocs()
24 b.ResetTimer()
25 for i := 0; i < b.N; i++ {
26 v.Mul(v, v)
27 }
28 })
29 b.Run("P521", func(b *testing.B) {
30 v := new(fiat.P521Element).One()
31 b.ReportAllocs()
32 b.ResetTimer()
33 for i := 0; i < b.N; i++ {
34 v.Mul(v, v)
35 }
36 })
37 }
38
39 func BenchmarkSquare(b *testing.B) {
40 b.Run("P224", func(b *testing.B) {
41 v := new(fiat.P224Element).One()
42 b.ReportAllocs()
43 b.ResetTimer()
44 for i := 0; i < b.N; i++ {
45 v.Square(v)
46 }
47 })
48 b.Run("P384", func(b *testing.B) {
49 v := new(fiat.P384Element).One()
50 b.ReportAllocs()
51 b.ResetTimer()
52 for i := 0; i < b.N; i++ {
53 v.Square(v)
54 }
55 })
56 b.Run("P521", func(b *testing.B) {
57 v := new(fiat.P521Element).One()
58 b.ReportAllocs()
59 b.ResetTimer()
60 for i := 0; i < b.N; i++ {
61 v.Square(v)
62 }
63 })
64 }
65
View as plain text