Files
edwards25519/field/fe_bench_test.go

83 lines
2.4 KiB
Go
Raw Permalink Normal View History

2026-03-06 21:58:16 +00:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Source: https://sources.truenas.cloud/code
// Import: sources.truenas.cloud/code/edwards25519/field
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 The Go Authors. All rights Reserved.
// Use of this source code is goverened by a BSD-style
// license that can be found in the LICENSE file.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package field
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import "testing"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkAdd(b *testing.B) {
x := new(Element).One()
y := new(Element).Add(x, x)
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Add(x, y)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkMultiply(b *testing.B) {
x := new(Element).One()
y := new(Element).Add(x, x)
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Multiply(x, y)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkSquare(b *testing.B) {
x := new(Element).Add(feOne, feOne)
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Square(x)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkInvert(b *testing.B) {
x := new(Element).Add(feOne, feOne)
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Invert(x)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkMult32(b *testing.B) {
x := new(Element).One()
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Mult32(x, 0xaa42aa42)
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func BenchmarkBytes(b *testing.B) {
x := new(Element).One()
b.ResetTimer()
for i := 0; i < b.N; i++ {
x.Bytes()
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////