-
Notifications
You must be signed in to change notification settings - Fork 2
/
charsets_test.go
79 lines (70 loc) · 1.18 KB
/
charsets_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
//
// Copyright 2018-2023 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
package semver
import (
"testing"
)
var result int
func BenchmarkNumericArray(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if numeric[c] {
count++
}
}
result = count
}
func BenchmarkNumericFunction(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if isNumeric(c) {
count++
}
}
result = count
}
func BenchmarkIdentifierArray(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if identifier[c] {
count++
}
}
result = count
}
func BenchmarkIdentifierFunction(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if isIdentifier(c) {
count++
}
}
result = count
}
func BenchmarkVersionSeparatorArray(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if versionSeparator[c] {
count++
}
}
result = count
}
func BenchmarkVersionSeparatorFunction(b *testing.B) {
count := 0
for n := 0; n < b.N; n++ {
c := byte(n)
if isVersionSeparator(c) {
count++
}
}
result = count
}