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

Optimizations 2 #64

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

anatoly-kussul
Copy link
Contributor

@anatoly-kussul anatoly-kussul commented Jan 9, 2025

At this point I was just curious about how much further I can push it.
Feel free to close this PR if you feel like this is too much.

benchmarks:

goos: linux
goarch: amd64
pkg: github.com/lithammer/shortuuid/v4
cpu: 12th Gen Intel(R) Core(TM) i5-12400F
                         │     old      │                new10                │
                         │    sec/op    │   sec/op     vs base                │
UUID-12                     119.6n ± 0%   103.6n ± 1%  -13.38% (p=0.000 n=10)
Encoding-12                 42.32n ± 0%   29.57n ± 2%  -30.12% (p=0.000 n=10)
EncodingB57_MB-12           116.5n ± 2%   114.6n ± 2%        ~ (p=0.117 n=10)
EncodingB16-12              151.9n ± 0%   119.1n ± 1%  -21.59% (p=0.000 n=10)
EncodingB16_MB-12           191.2n ± 2%   189.2n ± 1%        ~ (p=0.670 n=10)
Decoding-12                167.35n ± 1%   27.08n ± 1%  -83.82% (p=0.000 n=10)
DecodingB16-12              200.0n ± 1%   230.9n ± 1%  +15.43% (p=0.000 n=10)
DecodingB16_MB-12           249.9n ± 2%   265.8n ± 1%   +6.38% (p=0.000 n=10)
NewWithAlphabet-12          381.0n ± 2%   419.0n ± 1%   +9.97% (p=0.000 n=10)
NewWithAlphabetB16-12       293.6n ± 1%   256.7n ± 2%  -12.57% (p=0.000 n=10)
NewWithAlphabetB16_MB-12    403.5n ± 1%   425.5n ± 2%   +5.45% (p=0.000 n=10)
NewWithNamespace-12         166.3n ± 1%   151.1n ± 3%   -9.17% (p=0.000 n=10)
NewWithNamespaceHttp-12     169.8n ± 1%   151.8n ± 1%  -10.66% (p=0.000 n=10)
NewWithNamespaceHttps-12    167.4n ± 1%   152.9n ± 2%   -8.60% (p=0.000 n=10)
geomean                     177.4n        146.6n       -17.38%

@lithammer
Copy link
Owner

I see that this has some overlap with #63, would you mind rebasing to make it easier to review?

@anatoly-kussul
Copy link
Contributor Author

I see that this has some overlap with #63, would you mind rebasing to make it easier to review?

Sure, rebased

@anatoly-kussul
Copy link
Contributor Author

Did a bit of restructuring, moving base57 encoder as separate entity,
optimized default decoding.

updated benchmarks first comment

@anatoly-kussul
Copy link
Contributor Author

After I did restructuring, I realized that a lot of changes I made were unnecessary, so I reverted them.
Now the PR is a bit more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants