-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio_benchmark_test.go
83 lines (71 loc) · 1.55 KB
/
io_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package gonii
import (
"testing"
"github.com/okieraised/gonii/internal/utils"
"github.com/stretchr/testify/assert"
)
func Test_ReaderProfiling_90MBCompressed(t *testing.T) {
assert := assert.New(t)
fn := func() {
ReadNifti90MBCompressed()
}
err := utils.CPUProfilingFunc(fn, "./profiling_90Compressed.pprof")
assert.NoError(err)
}
func Test_ReaderProfiling_90MB(t *testing.T) {
assert := assert.New(t)
fn := func() {
ReadNifti90MB()
}
err := utils.CPUProfilingFunc(fn, "./profiling_90.pprof")
assert.NoError(err)
}
func BenchmarkNewNiiReader_90MBCompressed(b *testing.B) {
for i := 0; i < b.N; i++ {
ReadNifti90MBCompressed()
}
}
func BenchmarkNewNiiReader_90MB(b *testing.B) {
for i := 0; i < b.N; i++ {
ReadNifti90MB()
}
}
func BenchmarkNewNiiReader_2_2MB(b *testing.B) {
b.N = 100
for i := 0; i < b.N; i++ {
ReadNifti2_2MB()
}
}
func ReadNifti90MBCompressed() {
filePath := "/home/tripg/workspace/anim3.nii.gz"
rd, err := NewNiiReader(WithReadImageFile(filePath), WithReadRetainHeader(false))
if err != nil {
return
}
err = rd.Parse()
if err != nil {
return
}
}
func ReadNifti90MB() {
filePath := "/home/tripg/workspace/anim3.nii"
rd, err := NewNiiReader(WithReadImageFile(filePath), WithReadRetainHeader(false))
if err != nil {
return
}
err = rd.Parse()
if err != nil {
return
}
}
func ReadNifti2_2MB() {
filePath := "/home/tripg/workspace/int16.nii.gz"
rd, err := NewNiiReader(WithReadImageFile(filePath), WithReadRetainHeader(false))
if err != nil {
return
}
err = rd.Parse()
if err != nil {
return
}
}