Skip to content

Commit

Permalink
test: add benchmark for ValidHeaderFieldValueTable
Browse files Browse the repository at this point in the history
  • Loading branch information
welkeyever committed Jan 2, 2024
1 parent 984d36d commit 5ec37e9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/bytesconv/bytesconv_timing_test.go
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

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 3 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `gofumpt`-ed (gofumpt)
"golang.org/x/net/http/httpguts"

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `goimports`-ed (goimports)

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `goimports`-ed (goimports)

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `goimports`-ed (goimports)

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `goimports`-ed (goimports)

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `goimports`-ed (goimports)

Check failure on line 4 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `goimports`-ed (goimports)
"testing"

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.18)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.19)

File is not `gofumpt`-ed (gofumpt)

Check failure on line 5 in internal/bytesconv/bytesconv_timing_test.go

View workflow job for this annotation

GitHub Actions / lint-and-ut (1.20)

File is not `gofumpt`-ed (gofumpt)
)

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
}()
}
}
}

0 comments on commit 5ec37e9

Please sign in to comment.