forked from TrueCloudLab/neoneo-go
vm/bench: extend refcounter benchmarks
Adding an array multiple times leads to the fast update via `IncRC`. This hides the allocation that is there on the first addition. In this commit add another benchmark which measures Add/Remove together, to ensure that `switch` in `refCounter.Add` is entered. Benchmark results are meaningful, because `Add`/`Remove` have almost identical implementation. Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4531f79a4b
commit
59fbc689e4
1 changed files with 11 additions and 0 deletions
|
@ -55,3 +55,14 @@ func BenchmarkRefCounter_Add(b *testing.B) {
|
|||
rc.Add(a)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRefCounter_AddRemove(b *testing.B) {
|
||||
a := stackitem.NewArray([]stackitem.Item{})
|
||||
rc := newRefCounter()
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
rc.Add(a)
|
||||
rc.Remove(a)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue