go fiat_test 源码

2022-07-15 浏览 (911)

golang fiat_test 代码

文件路径:/src/crypto/internal/nistec/fiat/fiat_test.go

// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package fiat_test

import (
	"crypto/internal/nistec/fiat"
	"testing"
)

func BenchmarkMul(b *testing.B) {
	b.Run("P224", func(b *testing.B) {
		v := new(fiat.P224Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Mul(v, v)
		}
	})
	b.Run("P384", func(b *testing.B) {
		v := new(fiat.P384Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Mul(v, v)
		}
	})
	b.Run("P521", func(b *testing.B) {
		v := new(fiat.P521Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Mul(v, v)
		}
	})
}

func BenchmarkSquare(b *testing.B) {
	b.Run("P224", func(b *testing.B) {
		v := new(fiat.P224Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Square(v)
		}
	})
	b.Run("P384", func(b *testing.B) {
		v := new(fiat.P384Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Square(v)
		}
	})
	b.Run("P521", func(b *testing.B) {
		v := new(fiat.P521Element).One()
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			v.Square(v)
		}
	})
}

相关信息

go 源码目录

相关文章

go generate 源码

go p224 源码

go p224_fiat64 源码

go p224_invert 源码

go p256 源码

go p256_fiat64 源码

go p256_invert 源码

go p384 源码

go p384_fiat64 源码

go p384_invert 源码

  • 所属分类: 后端技术
  • 本文标签: golang
  • 版权声明: 本文链接 https://seaxiang.com/blog/21b74acf19924841bdedee48d0979c2b