From 620295efe3aedfb88234dcbbbee10290a1e731a4 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Fri, 6 Aug 2021 10:22:06 +0300 Subject: [PATCH] transaction: add benchmark for transaction serialization Signed-off-by: Evgeniy Stratonikov --- pkg/core/transaction/bench_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/core/transaction/bench_test.go b/pkg/core/transaction/bench_test.go index 991d729dc..763637680 100644 --- a/pkg/core/transaction/bench_test.go +++ b/pkg/core/transaction/bench_test.go @@ -64,3 +64,14 @@ func BenchmarkTransaction_Bytes(b *testing.B) { _ = tx.Bytes() } } + +func BenchmarkGetVarSize(b *testing.B) { + tx, err := NewTransactionFromBytes(benchTx) + require.NoError(b, err) + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _ = io.GetVarSize(tx) + } +}