-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbytes_test.go
More file actions
38 lines (32 loc) · 627 Bytes
/
bytes_test.go
File metadata and controls
38 lines (32 loc) · 627 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
package gocostmodel
import (
"bytes"
"testing"
)
var (
bt1 = []byte("This is probably a Medium-Size source string")
bt2 = []byte("z")
bt3 = []byte("is")
btix int
btout []byte
)
func BenchmarkByteIndex(b *testing.B) {
for i := 0; i < b.N; i++ {
btix = bytes.Index(bt1, bt2)
}
}
func BenchmarkByteReplace(b *testing.B) {
for i := 0; i < b.N; i++ {
btout = bytes.Replace(bt1, bt3, bt2, -1)
}
}
func BenchmarkByteToUpper(b *testing.B) {
for i := 0; i < b.N; i++ {
btout = bytes.ToUpper(bt1)
}
}
func BenchmarkByteToLower(b *testing.B) {
for i := 0; i < b.N; i++ {
btout = bytes.ToLower(bt1)
}
}