-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrfc3986_test.go
More file actions
41 lines (36 loc) · 772 Bytes
/
Copy pathrfc3986_test.go
File metadata and controls
41 lines (36 loc) · 772 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
38
39
40
41
package rfc3986_test
import (
"fmt"
"runtime"
"testing"
"github.com/colduction/rfc3986"
)
func benchPerCoreConfigs(b *testing.B, f func(b *testing.B)) {
b.Helper()
coreConfigs := []int{1, 2, 4, 8, 12}
for _, n := range coreConfigs {
name := fmt.Sprintf("%d cores", n)
b.Run(name, func(b *testing.B) {
runtime.GOMAXPROCS(n)
f(b)
})
}
}
func BenchmarkQueryEscape(b *testing.B) {
benchPerCoreConfigs(b, func(b *testing.B) {
b.RunParallel(func(b *testing.PB) {
for b.Next() {
rfc3986.QueryEscape(" Hello World! ")
}
})
})
}
func BenchmarkQueryUnescape(b *testing.B) {
benchPerCoreConfigs(b, func(b *testing.B) {
b.RunParallel(func(b *testing.PB) {
for b.Next() {
rfc3986.QueryUnescape("%20Hello%20World!%20")
}
})
})
}