forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bag_benchmark_test.go
58 lines (52 loc) · 959 Bytes
/
bag_benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package ids
import (
"crypto/rand"
"testing"
)
func BenchmarkBagListSmall(b *testing.B) {
smallLen := 5
bag := Bag{}
for i := 0; i < smallLen; i++ {
var id ID
if _, err := rand.Read(id[:]); err != nil {
b.Fatal(err)
}
bag.Add(id)
}
b.ResetTimer()
for n := 0; n < b.N; n++ {
bag.List()
}
}
func BenchmarkBagListMedium(b *testing.B) {
mediumLen := 25
bag := Bag{}
for i := 0; i < mediumLen; i++ {
var id ID
if _, err := rand.Read(id[:]); err != nil {
b.Fatal(err)
}
bag.Add(id)
}
b.ResetTimer()
for n := 0; n < b.N; n++ {
bag.List()
}
}
func BenchmarkBagListLarge(b *testing.B) {
largeLen := 100000
bag := Bag{}
for i := 0; i < largeLen; i++ {
var id ID
if _, err := rand.Read(id[:]); err != nil {
b.Fatal(err)
}
bag.Add(id)
}
b.ResetTimer()
for n := 0; n < b.N; n++ {
bag.List()
}
}