From e47cc1028fe71da871ae2b63275871332aafb353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Sun, 5 Jul 2026 22:16:47 +0200 Subject: [PATCH 1/3] fix: align float parsing with strconv and harden helper functions ParseFloat64/ParseFloat32 diverged from strconv.ParseFloat in three ways: digit-less inputs (".", "e5", "+.") returned 0 without an error, integer parts larger than uint64 returned ErrRange although float64 can represent them, and more than 16 fractional digits returned ErrRange. The parser now collects digits into a single mantissa with a decimal exponent, fixing all three cases while staying allocation-free. Further improvements: - ConvertToBytes: return 0 for negative sizes, support binary units (42KiB = 43008), document decimal vs binary semantics - GetMIME: case-insensitive extension lookup via internal ToLower, avoiding the platform-dependent mime fallback for upper-case input - Start/StopTimeStampUpdater: guard with a mutex to prevent double-close panics and races on concurrent use - ToString: handle error before fmt.Stringer, matching fmt precedence - Trim/TrimLeft/TrimRight: correct doc comments (single byte cutset) Co-Authored-By: Claude Fable 5 --- byteseq.go | 9 ++++--- common.go | 28 ++++++++++++++++------ common_test.go | 15 ++++++++++++ convert.go | 3 +++ convert_test.go | 4 ++++ http.go | 5 ++-- http_test.go | 7 ++++++ parse.go | 38 ++++++++++++++++------------- parse_test.go | 17 +++++++++---- time.go | 63 +++++++++++++++++++++++++++---------------------- 10 files changed, 127 insertions(+), 62 deletions(-) diff --git a/byteseq.go b/byteseq.go index abc9c06..b2f54a8 100644 --- a/byteseq.go +++ b/byteseq.go @@ -57,7 +57,8 @@ func EqualFold[S byteSeq](b, s S) bool { return true } -// TrimLeft is the equivalent of strings/bytes.TrimLeft +// TrimLeft removes all leading occurrences of the byte cutset from s. +// Unlike strings/bytes.TrimLeft, cutset is a single byte, not a set of characters. func TrimLeft[S byteSeq](s S, cutset byte) S { lenStr, start := len(s), 0 for start < lenStr && s[start] == cutset { @@ -66,7 +67,8 @@ func TrimLeft[S byteSeq](s S, cutset byte) S { return s[start:] } -// Trim is the equivalent of strings/bytes.Trim +// Trim removes all leading and trailing occurrences of the byte cutset from s. +// Unlike strings/bytes.Trim, cutset is a single byte, not a set of characters. func Trim[S byteSeq](s S, cutset byte) S { i, j := 0, len(s)-1 for ; i <= j; i++ { @@ -83,7 +85,8 @@ func Trim[S byteSeq](s S, cutset byte) S { return s[i : j+1] } -// TrimRight is the equivalent of strings/bytes.TrimRight +// TrimRight removes all trailing occurrences of the byte cutset from s. +// Unlike strings/bytes.TrimRight, cutset is a single byte, not a set of characters. func TrimRight[S byteSeq](s S, cutset byte) S { lenStr := len(s) for lenStr > 0 && s[lenStr-1] == cutset { diff --git a/common.go b/common.go index 8618f51..bf26680 100644 --- a/common.go +++ b/common.go @@ -127,7 +127,10 @@ func IncrementIPRange(ip net.IP) { } // ConvertToBytes returns integer size of bytes from human-readable string, ex. 42kb, 42M -// Returns 0 if string is unrecognized +// Decimal units are powers of 1000 (42k = 42000); binary units with an 'i' infix +// are powers of 1024 (42Ki = 43008). Note that ByteSize formats with powers of 1024, +// so use binary suffixes for a lossless round-trip. +// Returns 0 if the string is unrecognized or negative. func ConvertToBytes(humanReadableString string) int { strLen := len(humanReadableString) if strLen == 0 { @@ -189,7 +192,7 @@ func ConvertToBytes(humanReadableString string) int { if strings.IndexByte(numPart, '.') >= 0 { var err error size, err = ParseFloat64(numPart) - if err != nil { + if err != nil || size < 0 { return 0 } } else { @@ -201,17 +204,28 @@ func ConvertToBytes(humanReadableString string) int { } if unitPrefixPos > 0 { + // An 'i' after the unit prefix selects binary units (KiB = 1024). + binary := unitPrefixPos+1 < strLen && + (humanReadableString[unitPrefixPos+1] == 'i' || humanReadableString[unitPrefixPos+1] == 'I') + var decMul, binMul float64 switch humanReadableString[unitPrefixPos] { case 'k', 'K': - size *= 1e3 + decMul, binMul = 1e3, 1<<10 case 'm', 'M': - size *= 1e6 + decMul, binMul = 1e6, 1<<20 case 'g', 'G': - size *= 1e9 + decMul, binMul = 1e9, 1<<30 case 't', 'T': - size *= 1e12 + decMul, binMul = 1e12, 1<<40 case 'p', 'P': - size *= 1e15 + decMul, binMul = 1e15, 1<<50 + default: + decMul, binMul = 1, 1 + } + if binary { + size *= binMul + } else { + size *= decMul } } diff --git a/common_test.go b/common_test.go index 50541fc..ede0ba5 100644 --- a/common_test.go +++ b/common_test.go @@ -52,6 +52,7 @@ func Test_UUIDv4(t *testing.T) { res := UUIDv4() require.Len(t, res, 36) require.NotEqual(t, "00000000-0000-0000-0000-000000000000", res) + require.Regexp(t, `^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`, res) } func Test_UUIDv4_Concurrency(t *testing.T) { @@ -180,6 +181,20 @@ func Test_ConvertToBytes(t *testing.T) { require.Equal(t, 42*1000000000000000, ConvertToBytes("42PB")) require.Equal(t, 42*1000000000000000, ConvertToBytes("42pb")) + // Test binary units (KiB = 1024) + require.Equal(t, 42*1024, ConvertToBytes("42Ki")) + require.Equal(t, 42*1024, ConvertToBytes("42KiB")) + require.Equal(t, 42*1024, ConvertToBytes("42kib")) + require.Equal(t, 42*1024*1024, ConvertToBytes("42MiB")) + require.Equal(t, 42*1024*1024*1024, ConvertToBytes("42GiB")) + require.Equal(t, 42*1024*1024*1024*1024, ConvertToBytes("42TiB")) + require.Equal(t, 42*1024*1024*1024*1024*1024, ConvertToBytes("42PiB")) + require.Equal(t, int(1.5*1024), ConvertToBytes("1.5KiB")) + + // Negative sizes are unrecognized + require.Equal(t, 0, ConvertToBytes("-5k")) + require.Equal(t, 0, ConvertToBytes("-5.0k")) + // Test edge cases and error conditions require.Equal(t, 0, ConvertToBytes("string")) require.Equal(t, 0, ConvertToBytes("MB")) diff --git a/convert.go b/convert.go index 21422e5..38b3e66 100644 --- a/convert.go +++ b/convert.go @@ -150,6 +150,9 @@ func ToString(arg any, timeFormat ...string) string { return "" } return ToString(v.Interface(), timeFormat...) + // error before fmt.Stringer to match the fmt package's precedence + case error: + return v.Error() case fmt.Stringer: return v.String() // Handle common pointer types directly to avoid reflection diff --git a/convert_test.go b/convert_test.go index 97b5c81..c33dd1f 100644 --- a/convert_test.go +++ b/convert_test.go @@ -5,6 +5,7 @@ package utils import ( + "errors" "fmt" "math" "reflect" @@ -119,6 +120,9 @@ func Test_ToString(t *testing.T) { // fmt.Stringer {name: "fmt.Stringer", input: stringerSample, expected: "Stringer Value"}, + // error + {name: "error", input: errors.New("something failed"), expected: "something failed"}, + // Composite types (arrays, slices) {name: "[]string", input: []string{"Hello", "World"}, expected: "[Hello World]"}, {name: "[]int", input: []int{42, 21}, expected: "[42 21]"}, diff --git a/http.go b/http.go index 8baaf3e..99e762b 100644 --- a/http.go +++ b/http.go @@ -36,8 +36,9 @@ func GetMIME(extension string) string { extWithDot = "." + extension } - // Single map lookup with normalized key - if foundMime := mimeExtensions[extWithoutDot]; len(foundMime) > 0 { + // Single map lookup with normalized key. Extensions are matched + // case-insensitively; ToLower only allocates for upper-case input. + if foundMime := mimeExtensions[casestrings.ToLower(extWithoutDot)]; len(foundMime) > 0 { return foundMime } diff --git a/http_test.go b/http_test.go index eae124f..7a742e8 100644 --- a/http_test.go +++ b/http_test.go @@ -35,6 +35,13 @@ func Test_GetMIME(t *testing.T) { res = GetMIME("cbor") require.Equal(t, "application/cbor", res) + // upper-case extensions match case-insensitively + res = GetMIME("PNG") + require.Equal(t, "image/png", res) + + res = GetMIME(".JSON") + require.Equal(t, "application/json", res) + // empty case res = GetMIME("") require.Empty(t, res) diff --git a/parse.go b/parse.go index e3f5e1d..a596a56 100644 --- a/parse.go +++ b/parse.go @@ -6,7 +6,6 @@ import ( ) const ( - maxFracDigits = 16 maxUint64Cutoff = math.MaxUint64 / 10 maxUint64Cutlim = math.MaxUint64 % 10 ) @@ -249,22 +248,26 @@ func parseFloat[S byteSeq](fn string, s S) (float64, error) { return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrSyntax} } - var intPart uint64 + // Collect integer and fractional digits into a single mantissa and track + // the decimal exponent. Digits beyond uint64 precision are dropped: integer + // digits shift the exponent up, fractional digits are simply ignored. + var mantissa uint64 + var exp10 int + digits := 0 for i < len(s) { c := s[i] - '0' if c > 9 { break } - if intPart > maxUint64Cutoff || (intPart == maxUint64Cutoff && uint64(c) > maxUint64Cutlim) { - return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrRange} + if mantissa > maxUint64Cutoff || (mantissa == maxUint64Cutoff && uint64(c) > maxUint64Cutlim) { + exp10++ + } else { + mantissa = mantissa*10 + uint64(c) } - intPart = intPart*10 + uint64(c) + digits++ i++ } - var fracPart uint64 - var fracDiv uint64 = 1 - var fracDigits int if i < len(s) && s[i] == '.' { i++ for i < len(s) { @@ -272,16 +275,19 @@ func parseFloat[S byteSeq](fn string, s S) (float64, error) { if c > 9 { break } - if fracDigits >= maxFracDigits { - return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrRange} + if mantissa < maxUint64Cutoff || (mantissa == maxUint64Cutoff && uint64(c) <= maxUint64Cutlim) { + mantissa = mantissa*10 + uint64(c) + exp10-- } - fracPart = fracPart*10 + uint64(c) - fracDiv *= 10 - fracDigits++ + digits++ i++ } } + if digits == 0 { + return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrSyntax} + } + var expSign bool var exp int64 if i < len(s) && (s[i] == 'e' || s[i] == 'E') { @@ -321,11 +327,9 @@ func parseFloat[S byteSeq](fn string, s S) (float64, error) { if expSign { exp = -exp } + exp += int64(exp10) - f := float64(intPart) - if fracPart > 0 { - f += float64(fracPart) / float64(fracDiv) - } + f := float64(mantissa) if exp != 0 { f *= math.Pow10(int(exp)) } diff --git a/parse_test.go b/parse_test.go index 2973e25..70fea99 100644 --- a/parse_test.go +++ b/parse_test.go @@ -675,10 +675,15 @@ func Test_ParseFloat64(t *testing.T) { {strconv.FormatFloat(-math.MaxFloat64, 'g', -1, 64), -math.MaxFloat64, true}, {"5e-324", 0, true}, {"1e-400", 0, true}, - {"25000000000000000000e-18", 0, false}, - {"1234567891234567891234567", 0, false}, + {"25000000000000000000e-18", 25, true}, + {"1234567891234567891234567", 1.2345678912345679e24, true}, {"1.2345678912345678", 1.2345678912345678, true}, // large number - {"0.11111111111111119", 0, false}, + {"0.11111111111111119", 0.11111111111111119, true}, + {".", 0, false}, + {"+.", 0, false}, + {"-.", 0, false}, + {"e5", 0, false}, + {".e5", 0, false}, {"1.2.3", 0, false}, {"1e1.0", 0, false}, {"1e309", 0, false}, @@ -774,9 +779,11 @@ func Test_ParseFloat32(t *testing.T) { {"1e", 0, false, false}, {"1e+", 0, false, false}, {"1e-", 0, false, false}, - {"1234567891234567891234567", 0, false, false}, + {"1234567891234567891234567", 1.2345679e24, true, false}, {"1.2345678912345678", 1.2345679, true, false}, - {"0.11111111111111119", 0, false, false}, + {"0.11111111111111119", 0.11111112, true, false}, + {".", 0, false, false}, + {"e5", 0, false, false}, {"1.2.3", 0, false, false}, {"1e1.0", 0, false, false}, {"1e309", 0, false, false}, diff --git a/time.go b/time.go index 394a23c..91b970a 100644 --- a/time.go +++ b/time.go @@ -8,7 +8,7 @@ import ( var ( timestamp atomic.Uint32 - updaterOnce sync.Once + updaterMu sync.Mutex stopUpdater chan struct{} updaterDone chan struct{} ) @@ -20,39 +20,46 @@ func Timestamp() uint32 { } // StartTimeStampUpdater launches a background goroutine that updates the cached timestamp every second. -// It is safe to call multiple times; only the first call will start the updater. +// It is safe to call multiple times and from multiple goroutines; only one updater runs at a time. func StartTimeStampUpdater() { - updaterOnce.Do(func() { - timestamp.Store(uint32(time.Now().Unix())) - stopUpdater = make(chan struct{}) - updaterDone = make(chan struct{}) - - go func() { - ticker := time.NewTicker(time.Second) - defer ticker.Stop() - defer close(updaterDone) - - for { - select { - case <-ticker.C: - timestamp.Store(uint32(time.Now().Unix())) - case <-stopUpdater: - return - } + updaterMu.Lock() + defer updaterMu.Unlock() + if stopUpdater != nil { + return + } + + timestamp.Store(uint32(time.Now().Unix())) + stopUpdater = make(chan struct{}) + updaterDone = make(chan struct{}) + + go func(stop, done chan struct{}) { + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + defer close(done) + + for { + select { + case <-ticker.C: + timestamp.Store(uint32(time.Now().Unix())) + case <-stop: + return } - }() - }) + } + }(stopUpdater, updaterDone) } // StopTimeStampUpdater stops the background updater goroutine. // Call this on app shutdown to avoid leaking goroutines. +// It is safe to call multiple times and from multiple goroutines. func StopTimeStampUpdater() { - if stopUpdater != nil { - close(stopUpdater) - <-updaterDone - // Reset the sync.Once so StartTimeStampUpdater can be called again - updaterOnce = sync.Once{} - stopUpdater = nil - updaterDone = nil + updaterMu.Lock() + defer updaterMu.Unlock() + if stopUpdater == nil { + return } + + close(stopUpdater) + <-updaterDone + stopUpdater = nil + updaterDone = nil } From ae095a86c98c8a1908d28f0a9ff80056933d0a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Sun, 5 Jul 2026 22:16:47 +0200 Subject: [PATCH 2/3] docs(readme): refresh benchmark results Re-measured on the same environment (Apple M2 Pro, darwin/arm64). Co-Authored-By: Claude Fable 5 --- README.md | 634 +++++++++++++++++++++++++++--------------------------- 1 file changed, 317 insertions(+), 317 deletions(-) diff --git a/README.md b/README.md index 46242a0..5f560dd 100644 --- a/README.md +++ b/README.md @@ -20,345 +20,345 @@ cpu: Apple M2 Pro // go test ./... -benchmem -run=^$ -bench=Benchmark_ -count=1 # Case Conversion -Benchmark_ToLowerBytes/empty/fiber-12 593913379 1.975 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/empty/fiber/unsafe-12 657748088 1.845 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/empty/default-12 367040010 3.281 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/http-get/fiber-12 365235189 3.393 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/http-get/fiber/unsafe-12 239092582 5.144 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/http-get/default-12 63143354 18.46 ns/op 8 B/op 1 allocs/op -Benchmark_ToLowerBytes/http-get-upper/fiber-12 94304095 12.86 ns/op 3 B/op 1 allocs/op -Benchmark_ToLowerBytes/http-get-upper/fiber/unsafe-12 239366296 5.057 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/http-get-upper/default-12 86047208 14.00 ns/op 8 B/op 1 allocs/op -Benchmark_ToLowerBytes/header-content-type-mixed/fiber-12 45169880 26.27 ns/op 48 B/op 1 allocs/op -Benchmark_ToLowerBytes/header-content-type-mixed/fiber/unsafe-12 95687102 12.70 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/header-content-type-mixed/default-12 25045154 47.56 ns/op 48 B/op 1 allocs/op -Benchmark_ToLowerBytes/large-lower/fiber-12 43856107 28.39 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/large-lower/fiber/unsafe-12 62907780 19.56 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/large-lower/default-12 17712895 69.18 ns/op 64 B/op 1 allocs/op -Benchmark_ToLowerBytes/large-upper/fiber-12 34286121 34.08 ns/op 64 B/op 1 allocs/op -Benchmark_ToLowerBytes/large-upper/fiber/unsafe-12 61959598 19.37 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/large-upper/default-12 16091281 75.42 ns/op 64 B/op 1 allocs/op -Benchmark_ToLowerBytes/large-mixed/fiber-12 33481714 35.06 ns/op 64 B/op 1 allocs/op -Benchmark_ToLowerBytes/large-mixed/fiber/unsafe-12 62478574 19.36 ns/op 0 B/op 0 allocs/op -Benchmark_ToLowerBytes/large-mixed/default-12 16091731 75.18 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpperBytes/empty/fiber-12 620292880 1.946 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/empty/fiber/unsafe-12 642997940 1.840 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/empty/default-12 366694138 3.324 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/http-get/fiber-12 95312475 12.75 ns/op 3 B/op 1 allocs/op -Benchmark_ToUpperBytes/http-get/fiber/unsafe-12 236603360 5.055 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/http-get/default-12 86667109 14.19 ns/op 8 B/op 1 allocs/op -Benchmark_ToUpperBytes/http-get-upper/fiber-12 360987979 3.425 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/http-get-upper/fiber/unsafe-12 236142552 5.096 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/http-get-upper/default-12 61760695 19.24 ns/op 8 B/op 1 allocs/op -Benchmark_ToUpperBytes/header-content-type-mixed/fiber-12 44394090 27.55 ns/op 48 B/op 1 allocs/op -Benchmark_ToUpperBytes/header-content-type-mixed/fiber/unsafe-12 94647172 12.75 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/header-content-type-mixed/default-12 25090692 47.83 ns/op 48 B/op 1 allocs/op -Benchmark_ToUpperBytes/large-lower/fiber-12 35558892 34.73 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpperBytes/large-lower/fiber/unsafe-12 62620129 19.31 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/large-lower/default-12 15487833 76.16 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpperBytes/large-upper/fiber-12 43901836 27.54 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/large-upper/fiber/unsafe-12 62027790 20.57 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/large-upper/default-12 14579604 82.82 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpperBytes/large-mixed/fiber-12 33719427 35.99 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpperBytes/large-mixed/fiber/unsafe-12 62008428 21.01 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpperBytes/large-mixed/default-12 15469116 77.21 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpper/empty/fiber-12 613156160 1.955 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/empty/fiber/unsafe-12 649026514 1.838 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/empty/default-12 650956171 1.831 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/http-get/fiber-12 92095164 12.77 ns/op 3 B/op 1 allocs/op -Benchmark_ToUpper/http-get/fiber/unsafe-12 235750344 5.036 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/http-get/default-12 60473330 20.50 ns/op 8 B/op 1 allocs/op -Benchmark_ToUpper/http-get-upper/fiber-12 398272657 3.048 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/http-get-upper/fiber/unsafe-12 220124466 5.078 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/http-get-upper/default-12 233645295 5.051 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/header-content-type-mixed/fiber-12 36106831 33.14 ns/op 48 B/op 1 allocs/op -Benchmark_ToUpper/header-content-type-mixed/fiber/unsafe-12 93201168 12.83 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/header-content-type-mixed/default-12 11069166 107.7 ns/op 48 B/op 1 allocs/op -Benchmark_ToUpper/large-lower/fiber-12 29007373 41.16 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpper/large-lower/fiber/unsafe-12 61283246 19.47 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/large-lower/default-12 6855549 174.0 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpper/large-upper/fiber-12 43965034 28.00 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/large-upper/fiber/unsafe-12 53715409 20.68 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/large-upper/default-12 18805570 65.60 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/large-mixed/fiber-12 27005611 43.54 ns/op 64 B/op 1 allocs/op -Benchmark_ToUpper/large-mixed/fiber/unsafe-12 60924529 20.57 ns/op 0 B/op 0 allocs/op -Benchmark_ToUpper/large-mixed/default-12 5662490 212.0 ns/op 64 B/op 1 allocs/op -Benchmark_ToLower/empty/fiber-12 607541103 1.972 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/empty/fiber/unsafe-12 631531857 1.969 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/empty/default-12 638706405 1.872 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/http-get/fiber-12 390062401 3.080 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/http-get/fiber/unsafe-12 231204609 5.190 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/http-get/default-12 278482443 4.408 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/http-get-upper/fiber-12 91051068 13.16 ns/op 3 B/op 1 allocs/op -Benchmark_ToLower/http-get-upper/fiber/unsafe-12 233437356 5.168 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/http-get-upper/default-12 59555317 22.03 ns/op 8 B/op 1 allocs/op -Benchmark_ToLower/header-content-type-mixed/fiber-12 32247734 35.17 ns/op 48 B/op 1 allocs/op -Benchmark_ToLower/header-content-type-mixed/fiber/unsafe-12 92616117 12.98 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/header-content-type-mixed/default-12 16339488 74.21 ns/op 48 B/op 1 allocs/op -Benchmark_ToLower/large-lower/fiber-12 37544337 33.77 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/large-lower/fiber/unsafe-12 61856332 19.83 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/large-lower/default-12 23513985 50.17 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/large-upper/fiber-12 28177750 44.45 ns/op 64 B/op 1 allocs/op -Benchmark_ToLower/large-upper/fiber/unsafe-12 61319127 20.23 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/large-upper/default-12 6700268 180.1 ns/op 64 B/op 1 allocs/op -Benchmark_ToLower/large-mixed/fiber-12 26804186 45.68 ns/op 64 B/op 1 allocs/op -Benchmark_ToLower/large-mixed/fiber/unsafe-12 61659141 19.97 ns/op 0 B/op 0 allocs/op -Benchmark_ToLower/large-mixed/default-12 5614172 213.1 ns/op 64 B/op 1 allocs/op +Benchmark_ToLowerBytes/empty/fiber-12 601228760 1.955 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/empty/fiber/unsafe-12 601901127 1.977 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/empty/default-12 361526772 3.343 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/http-get/fiber-12 356280168 3.373 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/http-get/fiber/unsafe-12 232881622 5.121 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/http-get/default-12 64825149 18.35 ns/op 8 B/op 1 allocs/op +Benchmark_ToLowerBytes/http-get-upper/fiber-12 95134903 12.71 ns/op 3 B/op 1 allocs/op +Benchmark_ToLowerBytes/http-get-upper/fiber/unsafe-12 233711541 5.175 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/http-get-upper/default-12 83459391 13.94 ns/op 8 B/op 1 allocs/op +Benchmark_ToLowerBytes/header-content-type-mixed/fiber-12 46423608 25.82 ns/op 48 B/op 1 allocs/op +Benchmark_ToLowerBytes/header-content-type-mixed/fiber/unsafe-12 94087516 12.69 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/header-content-type-mixed/default-12 25226778 47.33 ns/op 48 B/op 1 allocs/op +Benchmark_ToLowerBytes/large-lower/fiber-12 42942836 27.95 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/large-lower/fiber/unsafe-12 61712125 19.44 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/large-lower/default-12 17121913 69.94 ns/op 64 B/op 1 allocs/op +Benchmark_ToLowerBytes/large-upper/fiber-12 36060220 33.69 ns/op 64 B/op 1 allocs/op +Benchmark_ToLowerBytes/large-upper/fiber/unsafe-12 61862710 19.45 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/large-upper/default-12 16092603 74.24 ns/op 64 B/op 1 allocs/op +Benchmark_ToLowerBytes/large-mixed/fiber-12 35001792 34.35 ns/op 64 B/op 1 allocs/op +Benchmark_ToLowerBytes/large-mixed/fiber/unsafe-12 62047836 19.42 ns/op 0 B/op 0 allocs/op +Benchmark_ToLowerBytes/large-mixed/default-12 16119986 74.45 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpperBytes/empty/fiber-12 621527377 1.948 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/empty/fiber/unsafe-12 620614620 1.903 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/empty/default-12 347387406 3.339 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/http-get/fiber-12 93976990 12.81 ns/op 3 B/op 1 allocs/op +Benchmark_ToUpperBytes/http-get/fiber/unsafe-12 228022617 5.177 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/http-get/default-12 80799015 14.77 ns/op 8 B/op 1 allocs/op +Benchmark_ToUpperBytes/http-get-upper/fiber-12 353756593 3.385 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/http-get-upper/fiber/unsafe-12 234419678 5.132 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/http-get-upper/default-12 63601288 18.92 ns/op 8 B/op 1 allocs/op +Benchmark_ToUpperBytes/header-content-type-mixed/fiber-12 44992688 26.51 ns/op 48 B/op 1 allocs/op +Benchmark_ToUpperBytes/header-content-type-mixed/fiber/unsafe-12 95225496 12.77 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/header-content-type-mixed/default-12 22269578 53.94 ns/op 48 B/op 1 allocs/op +Benchmark_ToUpperBytes/large-lower/fiber-12 35570046 33.42 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpperBytes/large-lower/fiber/unsafe-12 61963066 19.52 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/large-lower/default-12 14771874 80.05 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpperBytes/large-upper/fiber-12 43817876 27.94 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/large-upper/fiber/unsafe-12 61968400 19.39 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/large-upper/default-12 14641957 81.42 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpperBytes/large-mixed/fiber-12 35656184 34.25 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpperBytes/large-mixed/fiber/unsafe-12 56226717 19.48 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpperBytes/large-mixed/default-12 14955886 80.25 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpper/empty/fiber-12 539313216 2.018 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/empty/fiber/unsafe-12 634806298 1.889 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/empty/default-12 638947015 1.882 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/http-get/fiber-12 95414156 12.67 ns/op 3 B/op 1 allocs/op +Benchmark_ToUpper/http-get/fiber/unsafe-12 234368000 5.118 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/http-get/default-12 60732201 19.48 ns/op 8 B/op 1 allocs/op +Benchmark_ToUpper/http-get-upper/fiber-12 248156660 4.837 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/http-get-upper/fiber/unsafe-12 234148320 5.125 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/http-get-upper/default-12 234811851 5.098 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/header-content-type-mixed/fiber-12 45805240 26.20 ns/op 48 B/op 1 allocs/op +Benchmark_ToUpper/header-content-type-mixed/fiber/unsafe-12 93765258 12.83 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/header-content-type-mixed/default-12 11631184 103.2 ns/op 48 B/op 1 allocs/op +Benchmark_ToUpper/large-lower/fiber-12 36103797 33.35 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpper/large-lower/fiber/unsafe-12 56551980 20.95 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/large-lower/default-12 5996400 177.5 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpper/large-upper/fiber-12 28375362 42.48 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/large-upper/fiber/unsafe-12 61935218 19.44 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/large-upper/default-12 19255944 61.54 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/large-mixed/fiber-12 36390100 33.16 ns/op 64 B/op 1 allocs/op +Benchmark_ToUpper/large-mixed/fiber/unsafe-12 62494440 19.35 ns/op 0 B/op 0 allocs/op +Benchmark_ToUpper/large-mixed/default-12 5833207 204.4 ns/op 64 B/op 1 allocs/op +Benchmark_ToLower/empty/fiber-12 613171694 1.947 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/empty/fiber/unsafe-12 647631400 1.858 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/empty/default-12 638164638 1.883 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/http-get/fiber-12 394179825 3.058 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/http-get/fiber/unsafe-12 235441498 5.085 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/http-get/default-12 279097488 4.179 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/http-get-upper/fiber-12 98945953 12.38 ns/op 3 B/op 1 allocs/op +Benchmark_ToLower/http-get-upper/fiber/unsafe-12 236656982 5.051 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/http-get-upper/default-12 62779154 19.15 ns/op 8 B/op 1 allocs/op +Benchmark_ToLower/header-content-type-mixed/fiber-12 47738392 25.17 ns/op 48 B/op 1 allocs/op +Benchmark_ToLower/header-content-type-mixed/fiber/unsafe-12 94119801 12.68 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/header-content-type-mixed/default-12 18145400 65.65 ns/op 48 B/op 1 allocs/op +Benchmark_ToLower/large-lower/fiber-12 44083813 27.34 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/large-lower/fiber/unsafe-12 60995110 19.58 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/large-lower/default-12 24336615 48.71 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/large-upper/fiber-12 35895274 33.27 ns/op 64 B/op 1 allocs/op +Benchmark_ToLower/large-upper/fiber/unsafe-12 61949072 19.50 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/large-upper/default-12 7084752 168.0 ns/op 64 B/op 1 allocs/op +Benchmark_ToLower/large-mixed/fiber-12 35053681 34.56 ns/op 64 B/op 1 allocs/op +Benchmark_ToLower/large-mixed/fiber/unsafe-12 61658090 19.58 ns/op 0 B/op 0 allocs/op +Benchmark_ToLower/large-mixed/default-12 5924719 206.8 ns/op 64 B/op 1 allocs/op # Add Trailing Slash -Benchmark_AddTrailingSlashBytes/empty-12 1000000000 0.6118 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashBytes/slash-only-12 1000000000 0.9030 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashBytes/short-no-slash-12 100000000 12.17 ns/op 4 B/op 1 allocs/op -Benchmark_AddTrailingSlashBytes/short-with-slash-12 1000000000 0.9096 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashBytes/path-no-slash-12 79386301 13.31 ns/op 16 B/op 1 allocs/op -Benchmark_AddTrailingSlashBytes/path-with-slash-12 1000000000 0.9079 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashString/empty-12 1000000000 0.3001 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashString/slash-only-12 1000000000 0.5217 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashString/short-no-slash-12 100000000 13.37 ns/op 4 B/op 1 allocs/op -Benchmark_AddTrailingSlashString/short-with-slash-12 1000000000 0.4548 ns/op 0 B/op 0 allocs/op -Benchmark_AddTrailingSlashString/path-no-slash-12 84763720 16.71 ns/op 16 B/op 1 allocs/op -Benchmark_AddTrailingSlashString/path-with-slash-12 1000000000 0.4536 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashBytes/empty-12 1000000000 0.6968 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashBytes/slash-only-12 1000000000 1.072 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashBytes/short-no-slash-12 87295214 16.10 ns/op 4 B/op 1 allocs/op +Benchmark_AddTrailingSlashBytes/short-with-slash-12 1000000000 1.055 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashBytes/path-no-slash-12 49061860 28.34 ns/op 16 B/op 1 allocs/op +Benchmark_AddTrailingSlashBytes/path-with-slash-12 1000000000 1.053 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashString/empty-12 1000000000 0.2986 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashString/slash-only-12 1000000000 0.4552 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashString/short-no-slash-12 100000000 11.43 ns/op 4 B/op 1 allocs/op +Benchmark_AddTrailingSlashString/short-with-slash-12 1000000000 0.4569 ns/op 0 B/op 0 allocs/op +Benchmark_AddTrailingSlashString/path-no-slash-12 84621513 14.61 ns/op 16 B/op 1 allocs/op +Benchmark_AddTrailingSlashString/path-with-slash-12 1000000000 0.4529 ns/op 0 B/op 0 allocs/op # EqualFold -Benchmark_EqualFoldBytes/fiber-12 34227160 35.89 ns/op 0 B/op 0 allocs/op -Benchmark_EqualFoldBytes/default-12 17905046 68.31 ns/op 0 B/op 0 allocs/op -Benchmark_EqualFold/fiber-12 34215410 36.76 ns/op 0 B/op 0 allocs/op -Benchmark_EqualFold/default-12 17103853 69.62 ns/op 0 B/op 0 allocs/op +Benchmark_EqualFoldBytes/fiber-12 24560449 43.80 ns/op 0 B/op 0 allocs/op +Benchmark_EqualFoldBytes/default-12 14990294 84.85 ns/op 0 B/op 0 allocs/op +Benchmark_EqualFold/fiber-12 31785342 44.77 ns/op 0 B/op 0 allocs/op +Benchmark_EqualFold/default-12 12664594 87.50 ns/op 0 B/op 0 allocs/op # Trim -Benchmark_TrimRight/fiber-12 556198228 2.195 ns/op 0 B/op 0 allocs/op -Benchmark_TrimRight/default-12 394761454 3.080 ns/op 0 B/op 0 allocs/op -Benchmark_TrimRightBytes/fiber-12 552028600 2.188 ns/op 0 B/op 0 allocs/op -Benchmark_TrimRightBytes/default-12 364481850 3.382 ns/op 0 B/op 0 allocs/op -Benchmark_TrimLeft/fiber-12 493763746 2.439 ns/op 0 B/op 0 allocs/op -Benchmark_TrimLeft/default-12 394974064 3.147 ns/op 0 B/op 0 allocs/op -Benchmark_TrimLeftBytes/fiber-12 533978953 2.129 ns/op 0 B/op 0 allocs/op -Benchmark_TrimLeftBytes/default-12 390162962 3.090 ns/op 0 B/op 0 allocs/op -Benchmark_Trim/fiber-12 303470884 4.120 ns/op 0 B/op 0 allocs/op -Benchmark_Trim/default-12 238874899 4.889 ns/op 0 B/op 0 allocs/op -Benchmark_Trim/default.trimspace-12 230900814 5.395 ns/op 0 B/op 0 allocs/op -Benchmark_TrimBytes/fiber-12 302062202 3.963 ns/op 0 B/op 0 allocs/op -Benchmark_TrimBytes/default-12 245799558 5.052 ns/op 0 B/op 0 allocs/op -Benchmark_TrimBytes/default.trimspace-12 217547649 5.520 ns/op 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/empty-12 1000000000 0.3031 ns/op 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/empty-12 554941630 2.211 ns/op 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/spaces-12 378650127 3.139 ns/op 955.63 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/spaces-12 313411838 3.929 ns/op 763.64 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/ascii-word-12 325986266 3.682 ns/op 2444.19 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/ascii-word-12 260590963 4.751 ns/op 1894.19 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/auth-header-bearer-12 278654619 4.279 ns/op 5608.46 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/auth-header-bearer-12 217345236 5.665 ns/op 4236.48 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/auth-header-basic-12 374732025 3.245 ns/op 11711.17 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/auth-header-basic-12 245032184 5.138 ns/op 7395.35 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/accept-encoding-12 322936750 3.772 ns/op 5567.24 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/accept-encoding-12 259551775 4.791 ns/op 4383.20 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/content-type-12 327816716 3.700 ns/op 5404.76 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/content-type-12 261473678 4.851 ns/op 4122.61 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/x-forwarded-for-12 430371238 3.136 ns/op 8929.40 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/x-forwarded-for-12 259204014 4.351 ns/op 6434.58 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/query-params-12 297618063 3.686 ns/op 5425.87 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/query-params-12 260095944 4.591 ns/op 4356.73 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/ascii-long-12 244683963 4.594 ns/op 22203.55 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/ascii-long-12 196174795 6.097 ns/op 16728.77 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/no-trim-12 1000000000 0.6452 ns/op 7750.12 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/no-trim-12 431454468 2.758 ns/op 1813.07 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/fiber/mixed-whitespace-12 279402585 4.522 ns/op 3759.80 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpace/default/mixed-whitespace-12 216711007 5.540 ns/op 3068.59 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/empty-12 1000000000 0.3096 ns/op 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/empty-12 486190254 2.466 ns/op 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/spaces-12 350271897 3.119 ns/op 961.83 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/spaces-12 294683720 4.188 ns/op 716.36 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/ascii-word-12 328983026 3.690 ns/op 2438.91 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/ascii-word-12 242798146 5.181 ns/op 1737.10 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/auth-header-bearer-12 276373491 4.299 ns/op 5582.44 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/auth-header-bearer-12 203176566 6.066 ns/op 3956.37 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/auth-header-basic-12 371498816 3.203 ns/op 11863.40 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/auth-header-basic-12 233269664 5.123 ns/op 7417.55 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/accept-encoding-12 331386438 3.740 ns/op 5614.74 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/accept-encoding-12 248029371 5.101 ns/op 4116.44 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/content-type-12 324414853 3.624 ns/op 5518.54 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/content-type-12 250866906 4.764 ns/op 4198.35 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/x-forwarded-for-12 448704225 2.690 ns/op 10409.74 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/x-forwarded-for-12 267864716 5.395 ns/op 5189.83 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/query-params-12 298958100 3.821 ns/op 5234.49 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/query-params-12 247046188 4.859 ns/op 4116.00 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/ascii-long-12 259565295 4.594 ns/op 22201.52 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/ascii-long-12 188316823 6.343 ns/op 16079.55 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/no-trim-12 1000000000 0.6094 ns/op 8204.80 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/no-trim-12 395805396 3.032 ns/op 1649.01 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/fiber/mixed-whitespace-12 281619982 4.206 ns/op 4041.49 MB/s 0 B/op 0 allocs/op -Benchmark_TrimSpaceBytes/default/mixed-whitespace-12 209473969 5.716 ns/op 2974.30 MB/s 0 B/op 0 allocs/op +Benchmark_TrimRight/fiber-12 485636703 2.319 ns/op 0 B/op 0 allocs/op +Benchmark_TrimRight/default-12 389052968 2.984 ns/op 0 B/op 0 allocs/op +Benchmark_TrimRightBytes/fiber-12 570778065 2.153 ns/op 0 B/op 0 allocs/op +Benchmark_TrimRightBytes/default-12 354338642 3.378 ns/op 0 B/op 0 allocs/op +Benchmark_TrimLeft/fiber-12 546707935 2.161 ns/op 0 B/op 0 allocs/op +Benchmark_TrimLeft/default-12 395816548 3.839 ns/op 0 B/op 0 allocs/op +Benchmark_TrimLeftBytes/fiber-12 517814619 2.408 ns/op 0 B/op 0 allocs/op +Benchmark_TrimLeftBytes/default-12 344487759 3.479 ns/op 0 B/op 0 allocs/op +Benchmark_Trim/fiber-12 268123645 4.985 ns/op 0 B/op 0 allocs/op +Benchmark_Trim/default-12 216317569 5.603 ns/op 0 B/op 0 allocs/op +Benchmark_Trim/default.trimspace-12 196718382 6.164 ns/op 0 B/op 0 allocs/op +Benchmark_TrimBytes/fiber-12 276413652 4.682 ns/op 0 B/op 0 allocs/op +Benchmark_TrimBytes/default-12 206646734 6.416 ns/op 0 B/op 0 allocs/op +Benchmark_TrimBytes/default.trimspace-12 180688819 7.050 ns/op 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/empty-12 1000000000 0.3595 ns/op 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/empty-12 530890448 2.519 ns/op 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/spaces-12 274174633 3.941 ns/op 761.16 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/spaces-12 287224635 4.902 ns/op 611.98 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/ascii-word-12 291975805 4.577 ns/op 1966.40 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/ascii-word-12 205111491 5.559 ns/op 1618.98 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/auth-header-bearer-12 249115078 5.141 ns/op 4668.43 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/auth-header-bearer-12 181133806 6.330 ns/op 3791.28 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/auth-header-basic-12 358262827 3.202 ns/op 11868.28 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/auth-header-basic-12 246771914 4.861 ns/op 7817.71 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/accept-encoding-12 327337672 3.649 ns/op 5754.64 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/accept-encoding-12 263390455 4.551 ns/op 4614.63 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/content-type-12 328083764 3.669 ns/op 5451.76 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/content-type-12 263841824 4.557 ns/op 4388.98 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/x-forwarded-for-12 439685796 2.752 ns/op 10175.38 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/x-forwarded-for-12 281075425 4.245 ns/op 6595.73 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/query-params-12 327527677 3.652 ns/op 5476.47 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/query-params-12 263637592 4.546 ns/op 4399.23 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/ascii-long-12 263431845 4.665 ns/op 21864.72 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/ascii-long-12 196392247 6.130 ns/op 16640.29 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/no-trim-12 1000000000 0.6094 ns/op 8205.02 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/no-trim-12 438738540 2.760 ns/op 1811.78 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/fiber/mixed-whitespace-12 280189737 4.289 ns/op 3963.47 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpace/default/mixed-whitespace-12 220052497 5.464 ns/op 3111.01 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/empty-12 1000000000 0.3036 ns/op 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/empty-12 492696795 2.426 ns/op 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/spaces-12 390392758 3.090 ns/op 970.86 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/spaces-12 294485332 4.060 ns/op 738.89 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/ascii-word-12 326114242 3.662 ns/op 2457.47 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/ascii-word-12 245688716 4.901 ns/op 1836.35 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/auth-header-bearer-12 281842446 4.254 ns/op 5642.35 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/auth-header-bearer-12 208275072 5.765 ns/op 4162.93 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/auth-header-basic-12 375564568 3.186 ns/op 11925.46 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/auth-header-basic-12 232178205 5.161 ns/op 7362.63 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/accept-encoding-12 327044280 3.674 ns/op 5715.36 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/accept-encoding-12 246186018 4.882 ns/op 4301.08 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/content-type-12 327820933 3.673 ns/op 5445.58 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/content-type-12 247571902 4.851 ns/op 4123.23 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/x-forwarded-for-12 433509044 2.763 ns/op 10132.97 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/x-forwarded-for-12 263725153 4.551 ns/op 6153.07 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/query-params-12 327897222 3.666 ns/op 5455.18 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/query-params-12 246765888 4.859 ns/op 4115.96 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/ascii-long-12 262128422 4.558 ns/op 22377.17 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/ascii-long-12 188152813 6.363 ns/op 16030.46 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/no-trim-12 1000000000 0.6211 ns/op 8050.53 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/no-trim-12 395639230 3.036 ns/op 1646.73 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/fiber/mixed-whitespace-12 282314606 4.243 ns/op 4007.05 MB/s 0 B/op 0 allocs/op +Benchmark_TrimSpaceBytes/default/mixed-whitespace-12 207869355 5.766 ns/op 2948.57 MB/s 0 B/op 0 allocs/op # Convert -Benchmark_ConvertToBytes/fiber-12 305651658 3.974 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/int-12 494480786 2.455 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/int8-12 601754490 2.009 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/int16-12 480638928 2.507 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/int32-12 483084573 2.505 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/int64-12 485630560 2.572 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/uint-12 542968509 2.126 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/uint8-12 603426201 2.082 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/uint16-12 568713753 2.111 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/uint32-12 567709288 2.106 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/uint64-12 568810574 2.180 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/string-12 606042240 2.191 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/[]uint8-12 94285881 12.78 ns/op 16 B/op 1 allocs/op -Benchmark_ToString/bool-12 601565197 1.995 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/float32-12 24979378 48.10 ns/op 4 B/op 1 allocs/op -Benchmark_ToString/float64-12 17121148 70.77 ns/op 4 B/op 1 allocs/op -Benchmark_ToString/time.Time-12 12894415 93.74 ns/op 24 B/op 1 allocs/op -Benchmark_ToString/time.Time#01-12 12970261 95.06 ns/op 24 B/op 1 allocs/op -Benchmark_ToString/[]string-12 52706324 26.62 ns/op 16 B/op 1 allocs/op -Benchmark_ToString/[]int-12 51370597 24.19 ns/op 8 B/op 1 allocs/op -Benchmark_ToString/[2]int-12 31207941 38.93 ns/op 16 B/op 1 allocs/op -Benchmark_ToString/[][]int-12 8454266 142.9 ns/op 112 B/op 6 allocs/op -Benchmark_ToString/[]interface_{}-12 9656547 133.4 ns/op 72 B/op 3 allocs/op -Benchmark_ToString/utils.MyStringer-12 390543688 3.060 ns/op 0 B/op 0 allocs/op -Benchmark_ToString/utils.CustomType-12 11184109 106.9 ns/op 16 B/op 1 allocs/op -Benchmark_ToString_concurrency/int-12 1000000000 0.3039 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/int8-12 1000000000 0.2423 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/int16-12 1000000000 0.2901 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/int32-12 1000000000 0.2935 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/int64-12 1000000000 0.2856 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/uint-12 1000000000 0.3382 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/uint8-12 1000000000 0.2279 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/uint16-12 1000000000 0.2460 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/uint32-12 1000000000 0.2469 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/uint64-12 1000000000 0.2615 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/string-12 1000000000 0.2305 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/[]uint8-12 176655307 6.047 ns/op 16 B/op 1 allocs/op -Benchmark_ToString_concurrency/bool-12 1000000000 0.2306 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/float32-12 183723876 8.276 ns/op 4 B/op 1 allocs/op -Benchmark_ToString_concurrency/float64-12 121188367 9.445 ns/op 4 B/op 1 allocs/op -Benchmark_ToString_concurrency/time.Time-12 68860974 17.98 ns/op 24 B/op 1 allocs/op -Benchmark_ToString_concurrency/time.Time#01-12 65536016 18.02 ns/op 24 B/op 1 allocs/op -Benchmark_ToString_concurrency/[]string-12 159027694 8.212 ns/op 16 B/op 1 allocs/op -Benchmark_ToString_concurrency/[]int-12 203055362 5.631 ns/op 8 B/op 1 allocs/op -Benchmark_ToString_concurrency/[2]int-12 131550500 9.186 ns/op 16 B/op 1 allocs/op -Benchmark_ToString_concurrency/[][]int-12 21128588 55.64 ns/op 112 B/op 6 allocs/op -Benchmark_ToString_concurrency/[]interface_{}-12 30081375 38.26 ns/op 72 B/op 3 allocs/op -Benchmark_ToString_concurrency/utils.MyStringer-12 1000000000 0.3727 ns/op 0 B/op 0 allocs/op -Benchmark_ToString_concurrency/utils.CustomType-12 49417796 29.59 ns/op 16 B/op 1 allocs/op -Benchmark_UnsafeBytes/unsafe-12 1000000000 0.5450 ns/op 0 B/op 0 allocs/op -Benchmark_UnsafeBytes/default-12 80875700 14.54 ns/op 16 B/op 1 allocs/op -Benchmark_UnsafeString/unsafe-12 1000000000 0.3579 ns/op 0 B/op 0 allocs/op -Benchmark_UnsafeString/default-12 99855757 12.15 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/0-12 394155170 3.023 ns/op 0 B/op 0 allocs/op -Benchmark_ByteSize/1-12 64058362 18.38 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/500-12 58149043 21.64 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1024-12 58947781 20.26 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1126-12 52060172 23.14 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1048576-12 60832776 19.66 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1153024-12 51995977 22.68 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1073741824-12 61154545 19.64 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1180696576-12 52380780 23.06 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1099511627776-12 62655552 19.10 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1209033293824-12 53917438 23.08 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1125899906842624-12 60970962 18.98 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1238050092875776-12 55339809 21.64 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1152921504606846976-12 63578542 18.73 ns/op 16 B/op 1 allocs/op -Benchmark_ByteSize/1267763295104794624-12 55347254 21.74 ns/op 16 B/op 1 allocs/op +Benchmark_ConvertToBytes/fiber-12 303731499 3.947 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/int-12 497704682 2.406 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/int8-12 607933017 1.975 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/int16-12 484205890 2.481 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/int32-12 490413688 2.459 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/int64-12 500168806 2.405 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/uint-12 568876189 2.106 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/uint8-12 609816264 1.975 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/uint16-12 567892762 2.102 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/uint32-12 570461389 2.123 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/uint64-12 567259215 2.119 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/string-12 606332637 1.993 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/[]uint8-12 93052707 12.31 ns/op 16 B/op 1 allocs/op +Benchmark_ToString/bool-12 603432777 1.995 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/float32-12 25012396 48.04 ns/op 4 B/op 1 allocs/op +Benchmark_ToString/float64-12 17169336 70.51 ns/op 4 B/op 1 allocs/op +Benchmark_ToString/time.Time-12 12940731 92.84 ns/op 24 B/op 1 allocs/op +Benchmark_ToString/time.Time#01-12 12885784 93.52 ns/op 24 B/op 1 allocs/op +Benchmark_ToString/[]string-12 51672447 23.11 ns/op 16 B/op 1 allocs/op +Benchmark_ToString/[]int-12 51177982 23.30 ns/op 8 B/op 1 allocs/op +Benchmark_ToString/[2]int-12 29876820 38.88 ns/op 16 B/op 1 allocs/op +Benchmark_ToString/[][]int-12 8826847 136.3 ns/op 112 B/op 6 allocs/op +Benchmark_ToString/[]interface_{}-12 9783631 120.3 ns/op 72 B/op 3 allocs/op +Benchmark_ToString/utils.MyStringer-12 398624744 3.015 ns/op 0 B/op 0 allocs/op +Benchmark_ToString/utils.CustomType-12 11562967 104.5 ns/op 16 B/op 1 allocs/op +Benchmark_ToString_concurrency/int-12 1000000000 0.2675 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/int8-12 1000000000 0.2241 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/int16-12 1000000000 0.2761 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/int32-12 1000000000 0.2719 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/int64-12 1000000000 0.2673 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/uint-12 1000000000 0.2339 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/uint8-12 1000000000 0.2289 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/uint16-12 1000000000 0.2354 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/uint32-12 1000000000 0.2309 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/uint64-12 1000000000 0.2364 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/string-12 1000000000 0.2189 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/[]uint8-12 205632634 5.758 ns/op 16 B/op 1 allocs/op +Benchmark_ToString_concurrency/bool-12 1000000000 0.2346 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/float32-12 187598121 6.133 ns/op 4 B/op 1 allocs/op +Benchmark_ToString_concurrency/float64-12 135170138 8.719 ns/op 4 B/op 1 allocs/op +Benchmark_ToString_concurrency/time.Time-12 74157042 18.63 ns/op 24 B/op 1 allocs/op +Benchmark_ToString_concurrency/time.Time#01-12 61104981 20.85 ns/op 24 B/op 1 allocs/op +Benchmark_ToString_concurrency/[]string-12 148502100 7.790 ns/op 16 B/op 1 allocs/op +Benchmark_ToString_concurrency/[]int-12 230634176 5.118 ns/op 8 B/op 1 allocs/op +Benchmark_ToString_concurrency/[2]int-12 133293684 9.173 ns/op 16 B/op 1 allocs/op +Benchmark_ToString_concurrency/[][]int-12 22382804 54.81 ns/op 112 B/op 6 allocs/op +Benchmark_ToString_concurrency/[]interface_{}-12 33572145 36.32 ns/op 72 B/op 3 allocs/op +Benchmark_ToString_concurrency/utils.MyStringer-12 1000000000 0.3800 ns/op 0 B/op 0 allocs/op +Benchmark_ToString_concurrency/utils.CustomType-12 54238104 23.27 ns/op 16 B/op 1 allocs/op +Benchmark_UnsafeBytes/unsafe-12 1000000000 0.5654 ns/op 0 B/op 0 allocs/op +Benchmark_UnsafeBytes/default-12 88676498 13.68 ns/op 16 B/op 1 allocs/op +Benchmark_UnsafeString/unsafe-12 1000000000 0.3530 ns/op 0 B/op 0 allocs/op +Benchmark_UnsafeString/default-12 100000000 11.92 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/0-12 400988882 3.004 ns/op 0 B/op 0 allocs/op +Benchmark_ByteSize/1-12 68500806 17.65 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/500-12 60281438 19.95 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1024-12 59684172 19.67 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1126-12 53318622 26.05 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1048576-12 59837815 21.27 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1153024-12 52797439 22.84 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1073741824-12 60002750 19.76 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1180696576-12 52817191 22.15 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1099511627776-12 64727100 19.55 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1209033293824-12 54228812 21.65 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1125899906842624-12 64025749 18.28 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1238050092875776-12 57805672 22.45 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1152921504606846976-12 64201592 18.70 ns/op 16 B/op 1 allocs/op +Benchmark_ByteSize/1267763295104794624-12 58673847 21.37 ns/op 16 B/op 1 allocs/op # Format and Append -Benchmark_FormatUint/small/fiber-12 1000000000 0.3025 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint/small/strconv-12 584345623 2.084 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint/medium/fiber-12 125524198 10.04 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint/medium/strconv-12 57687223 21.13 ns/op 16 B/op 1 allocs/op -Benchmark_FormatUint/large/fiber-12 64259034 18.67 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint/large/strconv-12 44394020 26.98 ns/op 24 B/op 1 allocs/op -Benchmark_FormatInt/small_pos/fiber-12 609931978 1.994 ns/op 0 B/op 0 allocs/op -Benchmark_FormatInt/small_pos/strconv-12 579927732 2.046 ns/op 0 B/op 0 allocs/op -Benchmark_FormatInt/small_neg/fiber-12 611030502 1.969 ns/op 0 B/op 0 allocs/op -Benchmark_FormatInt/small_neg/strconv-12 82791925 14.13 ns/op 3 B/op 1 allocs/op -Benchmark_FormatInt/medium_pos/fiber-12 61593342 19.56 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt/medium_pos/strconv-12 58425434 21.66 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt/medium_neg/fiber-12 60677822 19.54 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt/medium_neg/strconv-12 59446896 20.23 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt/large_pos/fiber-12 46969258 25.61 ns/op 24 B/op 1 allocs/op -Benchmark_FormatInt/large_pos/strconv-12 44999648 26.57 ns/op 24 B/op 1 allocs/op -Benchmark_FormatInt/large_neg/fiber-12 45581593 26.18 ns/op 24 B/op 1 allocs/op -Benchmark_FormatInt/large_neg/strconv-12 45468108 26.83 ns/op 24 B/op 1 allocs/op -Benchmark_FormatUint32/fiber-12 126955321 9.411 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint32/strconv-12 58030117 21.34 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt32/fiber-12 60967604 19.60 ns/op 16 B/op 1 allocs/op -Benchmark_FormatInt32/strconv-12 59480410 20.12 ns/op 16 B/op 1 allocs/op -Benchmark_FormatUint16/fiber-12 164073385 7.314 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint16/strconv-12 74532424 16.78 ns/op 5 B/op 1 allocs/op -Benchmark_FormatInt16/fiber-12 74833182 15.94 ns/op 8 B/op 1 allocs/op -Benchmark_FormatInt16/strconv-12 75867136 16.05 ns/op 8 B/op 1 allocs/op -Benchmark_FormatUint8/fiber-12 1000000000 0.2999 ns/op 0 B/op 0 allocs/op -Benchmark_FormatUint8/strconv-12 82306642 14.64 ns/op 3 B/op 1 allocs/op -Benchmark_FormatInt8/fiber-12 1000000000 0.3015 ns/op 0 B/op 0 allocs/op -Benchmark_FormatInt8/strconv-12 80331591 14.71 ns/op 4 B/op 1 allocs/op -Benchmark_AppendUint/fiber-12 135872859 8.812 ns/op 0 B/op 0 allocs/op -Benchmark_AppendUint/strconv-12 100000000 10.44 ns/op 0 B/op 0 allocs/op -Benchmark_AppendInt/small_neg/fiber-12 345227787 3.321 ns/op 0 B/op 0 allocs/op -Benchmark_AppendInt/small_neg/strconv-12 210340929 5.744 ns/op 0 B/op 0 allocs/op -Benchmark_AppendInt/medium_neg/fiber-12 121853198 9.739 ns/op 0 B/op 0 allocs/op -Benchmark_AppendInt/medium_neg/strconv-12 100000000 10.04 ns/op 0 B/op 0 allocs/op +Benchmark_FormatUint/small/fiber-12 616120275 1.968 ns/op 0 B/op 0 allocs/op +Benchmark_FormatUint/small/strconv-12 597079038 1.990 ns/op 0 B/op 0 allocs/op +Benchmark_FormatUint/medium/fiber-12 61883050 18.90 ns/op 16 B/op 1 allocs/op +Benchmark_FormatUint/medium/strconv-12 60313885 20.38 ns/op 16 B/op 1 allocs/op +Benchmark_FormatUint/large/fiber-12 47939197 25.36 ns/op 24 B/op 1 allocs/op +Benchmark_FormatUint/large/strconv-12 44694955 26.49 ns/op 24 B/op 1 allocs/op +Benchmark_FormatInt/small_pos/fiber-12 608629350 1.963 ns/op 0 B/op 0 allocs/op +Benchmark_FormatInt/small_pos/strconv-12 618271995 1.956 ns/op 0 B/op 0 allocs/op +Benchmark_FormatInt/small_neg/fiber-12 626947920 1.919 ns/op 0 B/op 0 allocs/op +Benchmark_FormatInt/small_neg/strconv-12 87661094 14.05 ns/op 3 B/op 1 allocs/op +Benchmark_FormatInt/medium_pos/fiber-12 55510044 24.13 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt/medium_pos/strconv-12 49636088 20.89 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt/medium_neg/fiber-12 63894786 19.05 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt/medium_neg/strconv-12 62000552 19.78 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt/large_pos/fiber-12 47706525 25.50 ns/op 24 B/op 1 allocs/op +Benchmark_FormatInt/large_pos/strconv-12 45759099 26.59 ns/op 24 B/op 1 allocs/op +Benchmark_FormatInt/large_neg/fiber-12 47631805 25.46 ns/op 24 B/op 1 allocs/op +Benchmark_FormatInt/large_neg/strconv-12 45561183 26.65 ns/op 24 B/op 1 allocs/op +Benchmark_FormatUint32/fiber-12 62901873 19.08 ns/op 16 B/op 1 allocs/op +Benchmark_FormatUint32/strconv-12 59485326 20.61 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt32/fiber-12 61375447 19.29 ns/op 16 B/op 1 allocs/op +Benchmark_FormatInt32/strconv-12 60683575 19.99 ns/op 16 B/op 1 allocs/op +Benchmark_FormatUint16/fiber-12 80310759 15.03 ns/op 5 B/op 1 allocs/op +Benchmark_FormatUint16/strconv-12 74569866 15.74 ns/op 5 B/op 1 allocs/op +Benchmark_FormatInt16/fiber-12 76845693 15.44 ns/op 8 B/op 1 allocs/op +Benchmark_FormatInt16/strconv-12 78253000 15.80 ns/op 8 B/op 1 allocs/op +Benchmark_FormatUint8/fiber-12 604374918 1.973 ns/op 0 B/op 0 allocs/op +Benchmark_FormatUint8/strconv-12 82805967 14.56 ns/op 3 B/op 1 allocs/op +Benchmark_FormatInt8/fiber-12 610502032 1.969 ns/op 0 B/op 0 allocs/op +Benchmark_FormatInt8/strconv-12 82919455 14.59 ns/op 4 B/op 1 allocs/op +Benchmark_AppendUint/fiber-12 130580040 9.204 ns/op 0 B/op 0 allocs/op +Benchmark_AppendUint/strconv-12 100000000 10.15 ns/op 0 B/op 0 allocs/op +Benchmark_AppendInt/small_neg/fiber-12 363979753 3.293 ns/op 0 B/op 0 allocs/op +Benchmark_AppendInt/small_neg/strconv-12 212234758 5.689 ns/op 0 B/op 0 allocs/op +Benchmark_AppendInt/medium_neg/fiber-12 125316576 9.624 ns/op 0 B/op 0 allocs/op +Benchmark_AppendInt/medium_neg/strconv-12 122066809 9.835 ns/op 0 B/op 0 allocs/op # Token -Benchmark_GenerateSecureToken/16_bytes-12 4445361 284.0 ns/op 24 B/op 1 allocs/op -Benchmark_GenerateSecureToken/32_bytes-12 4071276 291.0 ns/op 48 B/op 1 allocs/op -Benchmark_TokenGenerators/UUIDv4-12 4021219 327.0 ns/op 64 B/op 2 allocs/op -Benchmark_TokenGenerators/SecureToken-12 4073481 287.3 ns/op 48 B/op 1 allocs/op +Benchmark_GenerateSecureToken/16_bytes-12 4395446 268.0 ns/op 24 B/op 1 allocs/op +Benchmark_GenerateSecureToken/32_bytes-12 4308816 277.5 ns/op 48 B/op 1 allocs/op +Benchmark_TokenGenerators/UUIDv4-12 4115958 294.5 ns/op 64 B/op 2 allocs/op +Benchmark_TokenGenerators/SecureToken-12 4320008 278.1 ns/op 48 B/op 1 allocs/op # HTTP -Benchmark_GetMIME/fiber-12 29202141 41.13 ns/op 0 B/op 0 allocs/op -Benchmark_GetMIME/default-12 16953927 73.52 ns/op 0 B/op 0 allocs/op -Benchmark_ParseVendorSpecificContentType/vendorContentType-12 154110751 7.784 ns/op 0 B/op 0 allocs/op -Benchmark_ParseVendorSpecificContentType/defaultContentType-12 396583869 3.023 ns/op 0 B/op 0 allocs/op -Benchmark_StatusMessage/fiber-12 1000000000 0.3396 ns/op 0 B/op 0 allocs/op -Benchmark_StatusMessage/default-12 447403729 2.694 ns/op 0 B/op 0 allocs/op +Benchmark_GetMIME/fiber-12 22006587 54.74 ns/op 0 B/op 0 allocs/op +Benchmark_GetMIME/default-12 17412228 69.29 ns/op 0 B/op 0 allocs/op +Benchmark_ParseVendorSpecificContentType/vendorContentType-12 125887742 9.981 ns/op 0 B/op 0 allocs/op +Benchmark_ParseVendorSpecificContentType/defaultContentType-12 353516896 3.504 ns/op 0 B/op 0 allocs/op +Benchmark_StatusMessage/fiber-12 1000000000 0.3850 ns/op 0 B/op 0 allocs/op +Benchmark_StatusMessage/default-12 431016290 2.751 ns/op 0 B/op 0 allocs/op # IP -Benchmark_IsIPv4/fiber-12 82770516 14.99 ns/op 0 B/op 0 allocs/op -Benchmark_IsIPv4/default-12 52222729 22.87 ns/op 0 B/op 0 allocs/op -Benchmark_IsIPv6/fiber-12 27058488 44.28 ns/op 0 B/op 0 allocs/op -Benchmark_IsIPv6/default-12 19518978 63.64 ns/op 0 B/op 0 allocs/op +Benchmark_IsIPv4/fiber-12 80343021 15.43 ns/op 0 B/op 0 allocs/op +Benchmark_IsIPv4/default-12 53110760 22.82 ns/op 0 B/op 0 allocs/op +Benchmark_IsIPv6/fiber-12 27125079 44.82 ns/op 0 B/op 0 allocs/op +Benchmark_IsIPv6/default-12 20017320 60.60 ns/op 0 B/op 0 allocs/op # Parse -Benchmark_ParseUint/fiber-12 171968007 6.984 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint/fiber_bytes-12 162498577 7.444 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint/default-12 87571795 13.70 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt/fiber-12 186597552 6.331 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt/fiber_bytes-12 180017686 6.686 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt/default-12 76678334 15.73 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt32/fiber-12 155367661 7.717 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt32/fiber_bytes-12 144681208 8.325 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt32/default-12 76537323 15.73 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt16/fiber-12 228710796 5.222 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt16/fiber_bytes-12 223933951 5.322 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt16/default-12 100000000 11.05 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt8/fiber-12 257930811 4.626 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt8/fiber_bytes-12 240602468 4.588 ns/op 0 B/op 0 allocs/op -Benchmark_ParseInt8/default-12 138314644 8.609 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint32/fiber-12 170833845 7.138 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint32/fiber_bytes-12 162105060 7.443 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint32/default-12 85408747 13.70 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint16/fiber-12 262682311 4.547 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint16/fiber_bytes-12 257359222 4.658 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint16/default-12 134532823 8.902 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint8/fiber-12 350422557 3.416 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint8/fiber_bytes-12 327501829 3.700 ns/op 0 B/op 0 allocs/op -Benchmark_ParseUint8/default-12 182633575 6.816 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat64/fiber-12 100000000 10.73 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat64/fiber_bytes-12 100000000 10.86 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat64/default-12 50053615 24.18 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat32/fiber-12 100000000 11.62 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat32/fiber_bytes-12 100000000 11.97 ns/op 0 B/op 0 allocs/op -Benchmark_ParseFloat32/default-12 46590180 25.98 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint/fiber-12 170572611 7.031 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint/fiber_bytes-12 161515281 7.414 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint/default-12 84878630 13.91 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt/fiber-12 188326305 6.554 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt/fiber_bytes-12 177401347 6.791 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt/default-12 74426298 16.02 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt32/fiber-12 152689100 7.792 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt32/fiber_bytes-12 143480342 8.350 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt32/default-12 75226464 15.95 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt16/fiber-12 233907660 5.214 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt16/fiber_bytes-12 218961453 5.362 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt16/default-12 100000000 11.20 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt8/fiber-12 277644391 4.368 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt8/fiber_bytes-12 255406502 4.720 ns/op 0 B/op 0 allocs/op +Benchmark_ParseInt8/default-12 137303502 8.716 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint32/fiber-12 168541228 7.201 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint32/fiber_bytes-12 160750947 7.499 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint32/default-12 87199530 13.95 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint16/fiber-12 259066075 4.625 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint16/fiber_bytes-12 249345403 4.822 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint16/default-12 132290673 9.031 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint8/fiber-12 346359704 3.473 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint8/fiber_bytes-12 296839494 4.125 ns/op 0 B/op 0 allocs/op +Benchmark_ParseUint8/default-12 180975388 6.673 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat64/fiber-12 84649861 14.23 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat64/fiber_bytes-12 83656969 14.19 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat64/default-12 48787262 24.61 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat32/fiber-12 78740156 15.25 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat32/fiber_bytes-12 78525037 15.15 ns/op 0 B/op 0 allocs/op +Benchmark_ParseFloat32/default-12 45575605 26.21 ns/op 0 B/op 0 allocs/op # Time -Benchmark_CalculateTimestamp/fiber-12 1000000000 0.3029 ns/op 0 B/op 0 allocs/op -Benchmark_CalculateTimestamp/default-12 36542426 32.77 ns/op 0 B/op 0 allocs/op -Benchmark_CalculateTimestamp/fiber_asserted-12 4240807 276.8 ns/op 13 B/op 2 allocs/op -Benchmark_CalculateTimestamp/default_asserted-12 3974042 305.6 ns/op 8 B/op 2 allocs/op +Benchmark_CalculateTimestamp/fiber-12 1000000000 0.3411 ns/op 0 B/op 0 allocs/op +Benchmark_CalculateTimestamp/default-12 36431808 33.04 ns/op 0 B/op 0 allocs/op +Benchmark_CalculateTimestamp/fiber_asserted-12 4388325 271.9 ns/op 10 B/op 2 allocs/op +Benchmark_CalculateTimestamp/default_asserted-12 3753456 303.1 ns/op 8 B/op 2 allocs/op # XML -Benchmark_GolangXMLEncoder-12 591470 2025 ns/op 4864 B/op 12 allocs/op -Benchmark_DefaultXMLEncoder-12 563848 2124 ns/op 4864 B/op 12 allocs/op -Benchmark_DefaultXMLDecoder-12 329698 3513 ns/op 2857 B/op 57 allocs/op +Benchmark_GolangXMLEncoder-12 581364 2083 ns/op 4864 B/op 12 allocs/op +Benchmark_DefaultXMLEncoder-12 591445 2080 ns/op 4864 B/op 12 allocs/op +Benchmark_DefaultXMLDecoder-12 326768 3486 ns/op 2862 B/op 57 allocs/op ``` See all the benchmarks under From 1406eada0d9eaf8dd394f894790f69586cf22869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Sun, 5 Jul 2026 22:27:21 +0200 Subject: [PATCH 3/3] fix: clamp combined exponent in parseFloat Clamping the parsed exponent to the 309/-325 sentinels before combining it with the mantissa exponent (exp10) corrupted results for long digit strings: "999...9e-390" (400 nines, true value ~1e10) came back as 1e75 because the parsed -390 was clamped to -325 and then shifted by +381. The parse loop now only saturates the exponent against int64 overflow and the clamp is applied to the combined exponent, which also keeps the int conversion for math.Pow10 safe on 32-bit platforms. Also skip the Pow10 scaling for a zero mantissa: 0 * Pow10(309) is NaN, which turned inputs like "0e400" into a spurious range error. Co-Authored-By: Claude Fable 5 --- parse.go | 25 ++++++++++++++++++------- parse_test.go | 7 +++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/parse.go b/parse.go index a596a56..c66a440 100644 --- a/parse.go +++ b/parse.go @@ -305,17 +305,17 @@ func parseFloat[S byteSeq](fn string, s S) (float64, error) { if i == len(s) { return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrSyntax} } + // Saturate the parsed exponent far beyond anything exp10 (bounded by + // the input length) could pull back into range. Clamping to the final + // range must wait until both are combined below. + const maxParsedExp = int64(1) << 50 for i < len(s) { c := s[i] - '0' if c > 9 { return 0, &strconv.NumError{Func: fn, Num: string(s), Err: strconv.ErrSyntax} } - exp = exp*10 + int64(c) - if !expSign && exp > 308 { - exp = 309 - } - if expSign && exp > 324 { - exp = 325 + if exp < maxParsedExp { + exp = exp*10 + int64(c) } i++ } @@ -327,10 +327,21 @@ func parseFloat[S byteSeq](fn string, s S) (float64, error) { if expSign { exp = -exp } + // Clamp the combined exponent to math.Pow10's saturation range so the + // int conversion below cannot wrap on 32-bit platforms for extremely + // long digit strings; larger magnitudes overflow (Inf, caught below) or + // underflow (Pow10 returns 0) anyway. exp += int64(exp10) + if exp > 309 { + exp = 309 + } else if exp < -325 { + exp = -325 + } f := float64(mantissa) - if exp != 0 { + // Skip scaling for a zero mantissa: 0 * Pow10(309) would be 0 * Inf = NaN + // and turn inputs like "0e400" into a spurious range error. + if exp != 0 && f != 0 { f *= math.Pow10(int(exp)) } if neg { diff --git a/parse_test.go b/parse_test.go index 70fea99..b86b239 100644 --- a/parse_test.go +++ b/parse_test.go @@ -3,6 +3,7 @@ package utils import ( "math" "strconv" + "strings" "testing" "github.com/stretchr/testify/require" @@ -701,6 +702,12 @@ func Test_ParseFloat64(t *testing.T) { {"123e1a", 0, false}, {"9999999999999999999", 1e19, true}, {"1.2.3", 0, false}, + {"0e400", 0, true}, + {"-0e400", 0, true}, + {"1e400", 0, false}, + {"0.1e1000", 0, false}, + {strings.Repeat("9", 400), 0, false}, + {strings.Repeat("9", 400) + "e-390", 1e10, true}, } for _, tt := range tests { v, err := ParseFloat64(tt.in)