-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain_test.go
80 lines (70 loc) · 1.42 KB
/
main_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"github.com/jochenboesmans/gedcom-parser/parse"
"os"
"runtime/pprof"
"testing"
"time"
)
func BenchmarkParseITISGedToJson(b *testing.B) {
cpuFile, err := os.Create("cpu-itis.prof")
if err != nil {
return
}
err = pprof.StartCPUProfile(cpuFile)
if err != nil {
return
}
parse.Parse("examples/ITIS.ged", "test-output/ITIS.json")
pprof.StopCPUProfile()
memFile, err := os.Create("mem-itis.prof")
if err != nil {
return
}
err = pprof.WriteHeapProfile(memFile)
if err != nil {
return
}
}
func BenchmarkParseHPGedToJson(b *testing.B) {
cpuFile, err := os.Create("cpu-hp.prof")
if err != nil {
return
}
err = pprof.StartCPUProfile(cpuFile)
if err != nil {
return
}
parse.Parse("examples/harry_potter.ged", "test-output/harry_potter.json")
pprof.StopCPUProfile()
memFile, err := os.Create("mem-hp.prof")
if err != nil {
return
}
time.Sleep(time.Second)
err = pprof.WriteHeapProfile(memFile)
if err != nil {
return
}
}
func BenchmarkParseWikiGodsGedToJson(b *testing.B) {
cpuFile, err := os.Create("cpu-wg.prof")
if err != nil {
return
}
err = pprof.StartCPUProfile(cpuFile)
if err != nil {
return
}
parse.Parse("examples/wikipedia_gods.ged", "test-output/wikipedia_gods.json")
pprof.StopCPUProfile()
memFile, err := os.Create("mem-wg.prof")
if err != nil {
return
}
time.Sleep(time.Second)
err = pprof.WriteHeapProfile(memFile)
if err != nil {
return
}
}