-
Notifications
You must be signed in to change notification settings - Fork 17
/
bench_test.go
63 lines (45 loc) · 1.46 KB
/
bench_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
// SPDX-FileCopyrightText: 2018-2024 caixw
//
// SPDX-License-Identifier: MIT
package watermark
import (
"os"
"testing"
"github.com/issue9/assert/v4"
)
func BenchmarkWater_MakeImage_500xJPEG(b *testing.B) {
a := assert.New(b, false)
copyBackgroundFile(a, "./testdata/output/bench.jpg", "./testdata/background.jpg")
w, err := NewFromFile("./testdata/watermark.jpg", 10, TopLeft)
a.NotError(err).NotNil(w)
file, err := os.OpenFile("./testdata/output/bench.jpg", os.O_RDWR, os.ModePerm)
a.NotError(err).NotNil(file)
defer file.Close()
for i := 0; i < b.N; i++ {
w.Mark(file, ".jpg")
}
}
func BenchmarkWater_MakeImage_500xPNG(b *testing.B) {
a := assert.New(b, false)
copyBackgroundFile(a, "./testdata/output/bench.png", "./testdata/background.png")
w, err := NewFromFile("./testdata/watermark.png", 10, TopLeft)
a.NotError(err).NotNil(w)
file, err := os.OpenFile("./testdata/output/bench.png", os.O_RDWR, os.ModePerm)
a.NotError(err).NotNil(file)
defer file.Close()
for i := 0; i < b.N; i++ {
w.Mark(file, ".png")
}
}
func BenchmarkWater_MakeImage_500xGIF(b *testing.B) {
a := assert.New(b, false)
copyBackgroundFile(a, "./testdata/output/bench.gif", "./testdata/background.gif")
w, err := NewFromFile("./testdata/watermark.gif", 10, TopLeft)
a.NotError(err).NotNil(w)
file, err := os.OpenFile("./testdata/output/bench.gif", os.O_RDWR, os.ModePerm)
a.NotError(err).NotNil(file)
defer file.Close()
for i := 0; i < b.N; i++ {
w.Mark(file, ".gif")
}
}