Source file src/crypto/ed25519/internal/edwards25519/field/fe_bench_test.go

     1  // Copyright (c) 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package field
     6  
     7  import "testing"
     8  
     9  func BenchmarkAdd(b *testing.B) {
    10  	var x, y Element
    11  	x.One()
    12  	y.Add(feOne, feOne)
    13  	b.ResetTimer()
    14  	for i := 0; i < b.N; i++ {
    15  		x.Add(&x, &y)
    16  	}
    17  }
    18  
    19  func BenchmarkMultiply(b *testing.B) {
    20  	var x, y Element
    21  	x.One()
    22  	y.Add(feOne, feOne)
    23  	b.ResetTimer()
    24  	for i := 0; i < b.N; i++ {
    25  		x.Multiply(&x, &y)
    26  	}
    27  }
    28  
    29  func BenchmarkMult32(b *testing.B) {
    30  	var x Element
    31  	x.One()
    32  	b.ResetTimer()
    33  	for i := 0; i < b.N; i++ {
    34  		x.Mult32(&x, 0xaa42aa42)
    35  	}
    36  }
    37  

View as plain text