From b85be5b7f77fb5efad7a6a332e5f8b40461617d1 Mon Sep 17 00:00:00 2001 From: a_bennassar Date: Tue, 1 Feb 2022 17:22:47 +0100 Subject: [PATCH] Add poseidon benchmark with 16 elements (#44) Add poseidon benchmark with 16 elements --- poseidon/poseidon_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/poseidon/poseidon_test.go b/poseidon/poseidon_test.go index 6e0e422..8c9e0b4 100644 --- a/poseidon/poseidon_test.go +++ b/poseidon/poseidon_test.go @@ -126,7 +126,7 @@ func TestInputsNotInField(t *testing.T) { require.Error(t, err, "inputs values not inside Finite Field") } -func BenchmarkPoseidonHash(b *testing.B) { +func BenchmarkPoseidonHash6Inputs(b *testing.B) { b0 := big.NewInt(0) b1 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061") //nolint:lll b2 := utils.NewIntFromString("12242166908188651009877250812424843524687801523336557272219921456462821518061") //nolint:lll @@ -137,3 +137,28 @@ func BenchmarkPoseidonHash(b *testing.B) { Hash(bigArray4) //nolint:errcheck,gosec } } + +func BenchmarkPoseidonHash16Inputs(b *testing.B) { + bigArray16 := []*big.Int{ + big.NewInt(1), + big.NewInt(2), + big.NewInt(3), + big.NewInt(4), + big.NewInt(5), + big.NewInt(6), + big.NewInt(7), + big.NewInt(8), + big.NewInt(9), + big.NewInt(10), + big.NewInt(11), + big.NewInt(12), + big.NewInt(13), + big.NewInt(14), + big.NewInt(15), + big.NewInt(16), + } + + for i := 0; i < b.N; i++ { + Hash(bigArray16) //nolint:errcheck,gosec + } +}