-
Notifications
You must be signed in to change notification settings - Fork 17
/
square_benchmark_test.go
49 lines (45 loc) · 1.32 KB
/
square_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
package square_test
import (
"fmt"
"testing"
"github.com/celestiaorg/go-square/v2"
"github.com/stretchr/testify/require"
)
func BenchmarkSquareConstruct(b *testing.B) {
for _, txCount := range []int{10, 100, 1000} {
b.Run(fmt.Sprintf("txCount=%d", txCount), func(b *testing.B) {
b.ReportAllocs()
txs := generateOrderedTxs(txCount/2, txCount/2, 1, 1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := square.Construct(txs, defaultMaxSquareSize, defaultSubtreeRootThreshold)
require.NoError(b, err)
}
})
}
}
func BenchmarkSquareBuild(b *testing.B) {
for _, txCount := range []int{10, 100, 1000, 10000} {
b.Run(fmt.Sprintf("txCount=%d", txCount), func(b *testing.B) {
b.ReportAllocs()
txs := generateMixedTxs(txCount/2, txCount/2, 1, 1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, err := square.Build(txs, defaultMaxSquareSize, defaultSubtreeRootThreshold)
require.NoError(b, err)
}
})
}
const txCount = 10
for _, blobSize := range []int{10, 100, 1000, 10000} {
b.Run(fmt.Sprintf("blobSize=%d", blobSize), func(b *testing.B) {
b.ReportAllocs()
txs := generateMixedTxs(0, txCount, 1, blobSize)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, err := square.Build(txs, defaultMaxSquareSize, defaultSubtreeRootThreshold)
require.NoError(b, err)
}
})
}
}