Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt, fmtsort: refactor SortedMap to use slice of structs for map sorting
This change refactors the SortedMap type in the fmtsort package from using two parallel slices for keys and values to a single slice of structs. This improves code clarity and reduces the complexity of handling map entries. Affected files and their respective functions have been updated to work with the new structure, including adjustments in fmt/print.go and text/template/exec.go to iterate over the new map representation. goos: darwin goarch: arm64 pkg: fmt cpu: Apple M2 Max │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ SprintfPadding-12 22.90n ± 14% 22.49n ± 5% ~ (p=0.481 n=10) SprintfEmpty-12 3.448n ± 8% 3.070n ± 11% -10.98% (p=0.029 n=10) SprintfString-12 7.635n ± 23% 7.567n ± 22% ~ (p=0.529 n=10) SprintfTruncateString-12 14.81n ± 8% 15.32n ± 9% ~ (p=0.315 n=10) SprintfTruncateBytes-12 14.19n ± 13% 15.72n ± 11% ~ (p=0.089 n=10) SprintfSlowParsingPath-12 9.048n ± 14% 9.271n ± 16% ~ (p=0.971 n=10) SprintfQuoteString-12 42.24n ± 6% 41.38n ± 5% ~ (p=0.143 n=10) SprintfInt-12 6.727n ± 16% 6.451n ± 14% ~ (p=0.239 n=10) SprintfIntInt-12 10.92n ± 15% 10.37n ± 10% ~ (p=0.063 n=10) SprintfPrefixedInt-12 31.47n ± 4% 30.71n ± 5% ~ (p=0.404 n=10) SprintfFloat-12 13.69n ± 10% 14.88n ± 11% ~ (p=0.171 n=10) SprintfComplex-12 51.06n ± 11% 50.50n ± 5% ~ (p=0.280 n=10) SprintfBoolean-12 7.432n ± 18% 7.566n ± 19% ~ (p=0.436 n=10) SprintfHexString-12 36.58n ± 14% 35.70n ± 2% ~ (p=0.072 n=10) SprintfHexBytes-12 48.01n ± 3% 47.04n ± 3% ~ (p=0.051 n=10) SprintfBytes-12 63.90n ± 7% 61.83n ± 3% ~ (p=0.123 n=10) SprintfStringer-12 37.36n ± 9% 39.58n ± 11% ~ (p=0.529 n=10) SprintfStructure-12 162.6n ± 3% 135.8n ± 5% -16.51% (p=0.000 n=10) ManyArgs-12 35.49n ± 18% 31.10n ± 31% ~ (p=0.971 n=10) FprintInt-12 33.48n ± 3% 33.30n ± 1% -0.54% (p=0.014 n=10) FprintfBytes-12 48.36n ± 1% 49.13n ± 2% +1.59% (p=0.002 n=10) FprintIntNoAlloc-12 33.44n ± 0% 33.24n ± 1% ~ (p=0.280 n=10) ScanInts-12 130.8µ ± 1% 132.4µ ± 2% +1.22% (p=0.000 n=10) ScanRecursiveInt-12 40.16m ± 2% 40.52m ± 2% ~ (p=0.052 n=10) ScanRecursiveIntReaderWrapper-12 40.15m ± 1% 41.22m ± 1% +2.68% (p=0.000 n=10) geomean 101.9n 100.7n -1.24% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ SprintfPadding-12 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfEmpty-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfString-12 5.000 ± 0% 5.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfTruncateString-12 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfTruncateBytes-12 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfSlowParsingPath-12 5.000 ± 0% 5.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfQuoteString-12 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfInt-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfIntInt-12 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfPrefixedInt-12 64.00 ± 0% 64.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfFloat-12 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfComplex-12 24.00 ± 0% 24.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfBoolean-12 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfHexString-12 80.00 ± 0% 80.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfHexBytes-12 104.0 ± 0% 104.0 ± 0% ~ (p=1.000 n=10) ¹ SprintfBytes-12 88.00 ± 0% 88.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfStringer-12 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹ SprintfStructure-12 216.0 ± 0% 168.0 ± 0% -22.22% (p=0.000 n=10) ManyArgs-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ FprintInt-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ FprintfBytes-12 24.00 ± 0% 24.00 ± 0% ~ (p=1.000 n=10) ¹ FprintIntNoAlloc-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ScanInts-12 14.87Ki ± 0% 14.87Ki ± 0% ~ (p=1.000 n=10) ¹ ScanRecursiveInt-12 16.32Ki ± 7% 16.94Ki ± 4% ~ (p=0.441 n=10) ScanRecursiveIntReaderWrapper-12 16.33Ki ± 1% 16.35Ki ± 8% ~ (p=0.068 n=10) geomean ² -0.84% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ SprintfPadding-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfEmpty-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfString-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfTruncateString-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfTruncateBytes-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfSlowParsingPath-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfQuoteString-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfInt-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfIntInt-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfPrefixedInt-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfFloat-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfComplex-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfBoolean-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfHexString-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfHexBytes-12 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfBytes-12 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfStringer-12 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹ SprintfStructure-12 8.000 ± 0% 6.000 ± 0% -25.00% (p=0.000 n=10) ManyArgs-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ FprintInt-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ FprintfBytes-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ FprintIntNoAlloc-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ScanInts-12 1.590k ± 0% 1.590k ± 0% ~ (p=1.000 n=10) ¹ ScanRecursiveInt-12 1.592k ± 0% 1.593k ± 0% ~ (p=0.650 n=10) ScanRecursiveIntReaderWrapper-12 1.594k ± 0% 1.594k ± 0% ~ (p=0.582 n=10) geomean ² -1.14% ² ¹ all samples are equal ² summaries must be >0 to compute geomean
- Loading branch information