github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekaerr/error_private_bench_test.go (about) 1 // Copyright © 2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekaerr 7 8 import ( 9 "testing" 10 ) 11 12 func BenchmarkErrorAllocate(b *testing.B) { 13 b.ReportAllocs() 14 b.ResetTimer() 15 for i := 0; i < b.N; i++ { 16 _ = allocError() 17 } 18 } 19 20 func BenchmarkErrorAllocateAndRelease(b *testing.B) { 21 b.ReportAllocs() 22 b.ResetTimer() 23 for i := 0; i < b.N; i++ { 24 releaseError(allocError().(*Error)) 25 } 26 } 27 28 func BenchmarkErrorAcquire(b *testing.B) { 29 b.ReportAllocs() 30 b.ResetTimer() 31 for i := 0; i < b.N; i++ { 32 _ = acquireError() 33 } 34 } 35 36 func BenchmarkErrorAcquireAndRelease(b *testing.B) { 37 b.ReportAllocs() 38 b.ResetTimer() 39 for i := 0; i < b.N; i++ { 40 releaseError(acquireError()) 41 } 42 }