mirror of https://github.com/gtank/ristretto255
internal/scalar: add benchmarks
This commit is contained in:
parent
a83cb39e47
commit
67661f6a4f
|
@ -6,6 +6,7 @@ package scalar
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
crand "crypto/rand"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
"testing/quick"
|
"testing/quick"
|
||||||
|
@ -135,3 +136,31 @@ func TestInvert(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkScalarAddition(b *testing.B) {
|
||||||
|
var rnd [128]byte
|
||||||
|
crand.Read(rnd[:])
|
||||||
|
s1 := (&Scalar{}).FromUniformBytes(rnd[0:64])
|
||||||
|
s2 := (&Scalar{}).FromUniformBytes(rnd[64:128])
|
||||||
|
t := &Scalar{}
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
t.Add(s1, s2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkScalarMultiplication(b *testing.B) {
|
||||||
|
var rnd [128]byte
|
||||||
|
crand.Read(rnd[:])
|
||||||
|
s1 := (&Scalar{}).FromUniformBytes(rnd[0:64])
|
||||||
|
s2 := (&Scalar{}).FromUniformBytes(rnd[64:128])
|
||||||
|
t := &Scalar{}
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
t.Mul(s1, s2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue