stackitem: avoid going through Value() in serialization

Doesn't change much, but still simpler.

name               old time/op    new time/op    delta
SerializeSimple-8     452ns ±10%     435ns ± 4%   ~     (p=0.356 n=10+9)

name               old alloc/op   new alloc/op   delta
SerializeSimple-8      432B ± 0%      432B ± 0%   ~     (all equal)

name               old allocs/op  new allocs/op  delta
SerializeSimple-8      7.00 ± 0%      7.00 ± 0%   ~     (all equal)
This commit is contained in:
Roman Khimov 2021-08-20 22:37:06 +03:00
parent 1a733ca456
commit d3198c3082
2 changed files with 17 additions and 8 deletions

View file

@ -207,3 +207,15 @@ func BenchmarkEncodeBinary(b *testing.B) {
}
}
}
func BenchmarkSerializeSimple(b *testing.B) {
s := NewStruct(nil)
s.Append(Make(100500))
s.Append(Make("1aada0032aba1ef6d1f0")) // Mimicking uint160.
for i := 0; i < b.N; i++ {
_, err := Serialize(s)
if err != nil {
b.FailNow()
}
}
}