summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonovan Hide <donovanhide@gmail.com>2015-05-09 14:12:34 +0100
committerAdam Langley <agl@google.com>2015-08-26 15:09:04 -0700
commitbb5ca2006d0a2601bb11a0d6da589e82b58388d4 (patch)
tree4fa0581af72307097aaaaaaf13e4d5f54685eaed
parent2c9297c0029af199c7cdf8f035cd6eea366e1977 (diff)
downloaded25519-bb5ca2006d0a2601bb11a0d6da589e82b58388d4.tar.xz
Add Benchmark
-rw-r--r--ed25519_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/ed25519_test.go b/ed25519_test.go
index 0dc2b13..290e340 100644
--- a/ed25519_test.go
+++ b/ed25519_test.go
@@ -103,3 +103,39 @@ func TestGolden(t *testing.T) {
}
}
}
+
+func BenchmarkKeyGeneration(b *testing.B) {
+ var zero zeroReader
+ for i := 0; i < b.N; i++ {
+ if _, _, err := GenerateKey(zero); err != nil {
+ b.Fatal(err)
+ }
+ }
+}
+
+func BenchmarkSigning(b *testing.B) {
+ var zero zeroReader
+ _, priv, err := GenerateKey(zero)
+ if err != nil {
+ b.Fatal(err)
+ }
+ message := []byte("Hello, world!")
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ Sign(priv, message)
+ }
+}
+
+func BenchmarkVerification(b *testing.B) {
+ var zero zeroReader
+ pub, priv, err := GenerateKey(zero)
+ if err != nil {
+ b.Fatal(err)
+ }
+ message := []byte("Hello, world!")
+ signature := Sign(priv, message)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ Verify(pub, message, signature)
+ }
+}