-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package bytesconv | ||
|
||
import ( | ||
Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.20)
Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.19)
|
||
"golang.org/x/net/http/httpguts" | ||
Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.20)
Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.19)
|
||
"testing" | ||
Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.18)
Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.20)
Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go GitHub Actions / lint-and-ut (1.19)
|
||
) | ||
|
||
func BenchmarkValidHeaderFiledValueTable(b *testing.B) { | ||
// Test all characters | ||
allBytes := make([]string, 0) | ||
for i := 0; i < 256; i++ { | ||
allBytes = append(allBytes, string([]byte{byte(i)})) | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
for _, s := range allBytes { | ||
_ = httpguts.ValidHeaderFieldValue(s) | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkValidHeaderFiledValueTableHertz(b *testing.B) { | ||
// Test all characters | ||
allBytes := make([]byte, 0) | ||
for i := 0; i < 256; i++ { | ||
allBytes = append(allBytes, byte(i)) | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
for _, s := range allBytes { | ||
_ = func() bool { | ||
return ValidHeaderFieldValueTable[s] != 0 | ||
}() | ||
} | ||
} | ||
} |