Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimise reading ints and longs #348

Merged
merged 1 commit into from
Jan 29, 2024
Merged

feat: optimise reading ints and longs #348

merged 1 commit into from
Jan 29, 2024

Conversation

nrwiersma
Copy link
Member

This PR optimises the Reader.ReadInt and Reader.ReadLong functions.

The benchmarked change is as follows:

name                      old time/op    new time/op    delta
SuperheroDecode-8            265ns ± 1%     244ns ± 1%  -7.95%  (p=0.000 n=10+10)
SuperheroEncode-8            200ns ± 0%     204ns ± 2%  +2.15%  (p=0.000 n=10+10)
PartialSuperheroDecode-8     120ns ± 0%     109ns ± 1%  -9.34%  (p=0.000 n=10+10)
SuperheroGenericDecode-8    23.8µs ± 1%    23.6µs ± 0%  -0.69%  (p=0.000 n=10+8)
SuperheroGenericEncode-8     268ns ± 3%     252ns ± 0%  -6.01%  (p=0.000 n=10+10)
SuperheroWriteFlush-8        164ns ± 1%     164ns ± 0%  +0.43%  (p=0.002 n=9+10)

name                      old alloc/op   new alloc/op   delta
SuperheroDecode-8            47.0B ± 0%     47.0B ± 0%    ~     (all equal)
SuperheroEncode-8             112B ± 0%      112B ± 0%    ~     (all equal)
PartialSuperheroDecode-8     9.00B ± 0%     9.00B ± 0%    ~     (all equal)
SuperheroGenericDecode-8    8.37kB ± 0%    8.37kB ± 0%    ~     (all equal)
SuperheroGenericEncode-8     80.0B ± 0%     80.0B ± 0%    ~     (all equal)
SuperheroWriteFlush-8        0.00B          0.00B         ~     (all equal)

name                      old allocs/op  new allocs/op  delta
SuperheroDecode-8             0.00           0.00         ~     (all equal)
SuperheroEncode-8             1.00 ± 0%      1.00 ± 0%    ~     (all equal)
PartialSuperheroDecode-8      0.00           0.00         ~     (all equal)
SuperheroGenericDecode-8       303 ± 0%       303 ± 0%    ~     (all equal)
SuperheroGenericEncode-8      3.00 ± 0%      3.00 ± 0%    ~     (all equal)
SuperheroWriteFlush-8         0.00           0.00         ~     (all equal)

@nrwiersma nrwiersma self-assigned this Jan 24, 2024
@nrwiersma nrwiersma merged commit 832df22 into main Jan 29, 2024
2 of 3 checks passed
@nrwiersma nrwiersma deleted the optimise-read-num branch January 29, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant