Closed DrJosh9000 closed 7 months ago
I ran the benchmarks on another computer I had handy, here they are for posterity. (Linux under WSL)
goos: linux
goarch: amd64
pkg: github.com/buildkite/terminal-to-html/v3
cpu: 12th Gen Intel(R) Core(TM) i9-12900K
│ baseline-linux-amd64.txt │ packed-linux-amd64.txt │
│ sec/op │ sec/op vs base │
RendererControl-24 443.6n ± 1% 369.8n ± 1% -16.66% (p=0.000 n=30)
RendererCurl-24 5.344µ ± 0% 5.641µ ± 0% +5.57% (p=0.000 n=30)
RendererHomer-24 12.22µ ± 0% 11.39µ ± 0% -6.76% (p=0.000 n=30)
RendererDockerPull-24 20.13µ ± 0% 20.15µ ± 0% ~ (p=0.188 n=30)
RendererPikachu-24 538.5µ ± 0% 516.8µ ± 0% -4.02% (p=0.000 n=30)
RendererNpm-24 12.83m ± 1% 11.38m ± 1% -11.35% (p=0.000 n=30)
geomean 39.89µ 37.58µ -5.80%
│ baseline-linux-amd64.txt │ packed-linux-amd64.txt │
│ B/op │ B/op vs base │
RendererControl-24 2.227Ki ± 0% 1.492Ki ± 0% -32.98% (p=0.000 n=30)
RendererCurl-24 10.766Ki ± 0% 7.766Ki ± 0% -27.87% (p=0.000 n=30)
RendererHomer-24 46.91Ki ± 0% 33.41Ki ± 0% -28.78% (p=0.000 n=30)
RendererDockerPull-24 48.41Ki ± 0% 33.67Ki ± 0% -30.44% (p=0.000 n=30)
RendererPikachu-24 767.6Ki ± 0% 652.4Ki ± 0% -15.01% (p=0.000 n=30)
RendererNpm-24 24.26Mi ± 0% 18.44Mi ± 0% -23.99% (p=0.000 n=30)
geomean 100.6Ki 73.73Ki -26.73%
│ baseline-linux-amd64.txt │ packed-linux-amd64.txt │
│ allocs/op │ allocs/op vs base │
RendererControl-24 9.000 ± 0% 9.000 ± 0% ~ (p=1.000 n=30) ¹
RendererCurl-24 36.00 ± 0% 35.00 ± 0% -2.78% (p=0.000 n=30)
RendererHomer-24 134.0 ± 0% 133.0 ± 0% -0.75% (p=0.000 n=30)
RendererDockerPull-24 193.0 ± 0% 193.0 ± 0% ~ (p=1.000 n=30) ¹
RendererPikachu-24 16.16k ± 0% 14.35k ± 0% -11.23% (p=0.000 n=30)
RendererNpm-24 183.2k ± 0% 158.9k ± 0% -13.27% (p=0.000 n=30)
geomean 540.1 514.0 -4.83%
¹ all samples are equal
The old node consists of the rune (
blob
), which is an int32, plus two pointers. On a 32-bit platform these align nicely. On 64-bit, the compiler typically wastes 4 bytes on padding for alignment.Storing style as a packed int, and replacing *style with style, has a few benefits:
Also it's faster and uses less memory: