-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathbenchmark_test.go
54 lines (49 loc) · 1.12 KB
/
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
package tlb
import (
"os"
"testing"
"github.com/tonkeeper/tongo/boc"
)
func Benchmark_Tlb_Unmarshal(b *testing.B) {
data, err := os.ReadFile("../testdata/raw-13516764.bin")
if err != nil {
b.Errorf("ReadFile() failed: %v", err)
}
cell, err := boc.DeserializeBoc(data)
if err != nil {
b.Errorf("boc.DeserializeBoc() failed: %v", err)
}
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
cell[0].ResetCounters()
var block Block
decoder := NewDecoder()
err = decoder.Unmarshal(cell[0], &block)
if err != nil {
b.Errorf("Unmarshal() failed: %v", err)
}
}
}
func Test_block(b *testing.T) {
data, err := os.ReadFile("testdata/block-1/block.bin")
if err != nil {
b.Errorf("ReadFile() failed: %v", err)
}
cell, err := boc.DeserializeBoc(data)
if err != nil {
b.Errorf("boc.DeserializeBoc() failed: %v", err)
}
var block Block
decoder := NewDecoder()
err = decoder.Unmarshal(cell[0], &block)
if err != nil {
b.Errorf("Unmarshal() failed: %v", err)
}
for _, tx := range block.AllTransactions() {
_, err := tx.SourceBoc()
if err != nil {
b.Errorf("SourceBoc() failed: %v", err)
}
}
}