From 4b9ab62990db9c89df979ea1470d343703a07494 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 25 Feb 2025 13:05:39 +0100 Subject: [PATCH] core/types: add benchmark --- core/types/transaction_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 17a7dda357..3cebc6ca76 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -576,3 +576,22 @@ func TestYParityJSONUnmarshalling(t *testing.T) { } } } + +func BenchmarkHash(b *testing.B) { + signer := NewLondonSigner(big.NewInt(1)) + to := common.Address{} + tx := NewTx(&DynamicFeeTx{ + ChainID: big.NewInt(123), + Nonce: 1, + Gas: 1000000, + To: &to, + Value: big.NewInt(1), + GasTipCap: big.NewInt(500), + GasFeeCap: big.NewInt(500), + }) + for i := 0; i < b.N; i++ { + signer.Hash(tx) + } +} + +// BenchmarkHash-8 541969 2320 ns/op 240 B/op 6 allocs/op