-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathbench_test.go
More file actions
37 lines (34 loc) · 729 Bytes
/
bench_test.go
File metadata and controls
37 lines (34 loc) · 729 Bytes
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
package triangle
import (
"bytes"
"image"
_ "image/png"
"io/ioutil"
"testing"
)
func BenchmarkDraw(b *testing.B) {
buf, err := ioutil.ReadFile("./output/sample_0.png")
if err != nil {
b.Skipf("Failed opening test file: %v", err)
}
img, _, err := image.Decode(bytes.NewBuffer(buf))
if err != nil {
b.Skipf("Failed decoding image: %v", err)
}
proc := Processor{
MaxPoints: 2500,
BlurRadius: 2,
SobelThreshold: 10,
PointsThreshold: 20,
StrokeWidth: 0,
Wireframe: 0,
}
p := Image{Processor: proc}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, _, err = p.Draw(img, proc, func() {})
if err != nil {
b.Fatalf("Failed drawing triangle benchmark image: %v", err)
}
}
}