From 00b0d4411f28a6146854746380d51195e6f4bfbc Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 23 Jan 2023 18:40:27 +0000 Subject: [PATCH] tests(evm): add benchmark tests setup for params (#1623) (#1627) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tests: add benchmark tests setup * fix: localized benchmark tests to keeper * update benchmark Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> (cherry picked from commit 9305788d885ed16df9ece06daef4193ecd9df1f5) Co-authored-by: Vladislav Varadinov --- x/evm/keeper/keeper_test.go | 4 ++++ x/evm/keeper/params_benchmark_test.go | 30 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 x/evm/keeper/params_benchmark_test.go diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index c767ea49..1b895277 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "math" "math/big" + "os" "testing" "time" @@ -77,6 +78,9 @@ type KeeperTestSuite struct { var s *KeeperTestSuite func TestKeeperTestSuite(t *testing.T) { + if os.Getenv("benchmark") != "" { + t.Skip("Skipping Gingko Test") + } s = new(KeeperTestSuite) s.enableFeemarket = false s.enableLondonHF = true diff --git a/x/evm/keeper/params_benchmark_test.go b/x/evm/keeper/params_benchmark_test.go new file mode 100644 index 00000000..b42529e4 --- /dev/null +++ b/x/evm/keeper/params_benchmark_test.go @@ -0,0 +1,30 @@ +package keeper_test + +import ( + "testing" + + "github.com/evmos/ethermint/x/evm/types" +) + +func BenchmarkSetParams(b *testing.B) { + suite := KeeperTestSuite{} + suite.SetupTestWithT(b) + params := types.DefaultParams() + + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = suite.app.EvmKeeper.SetParams(suite.ctx, params) + } +} + +func BenchmarkGetParams(b *testing.B) { + suite := KeeperTestSuite{} + suite.SetupTestWithT(b) + + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + _ = suite.app.EvmKeeper.GetParams(suite.ctx) + } +}