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

transform once #57

Merged
merged 2 commits into from
May 9, 2023
Merged

transform once #57

merged 2 commits into from
May 9, 2023

Conversation

josharian
Copy link
Contributor

  • add BenchmarkFold
  • only string transform source once when examining multiple targets

josharian added 2 commits May 4, 2023 15:23
With some simple subbenchmarks.
This isn't a particularly varied test,
as all the target strings are identical,
but it's enough to get some basic coverage.
The slight match CPU regression is due to an extra function call:
match now calls matchTransformed.
That could be inlined if desired, at the cost of some repetition.


goos: darwin
goarch: arm64
pkg: github.com/lithammer/fuzzysearch/fuzzy
                              │      a      │                  b                  │
                              │   sec/op    │   sec/op     vs base                │
Match-8                         16.06n ± 2%   16.65n ± 2%   +3.67% (p=0.000 n=10)
MatchBigLate-8                  1.009µ ± 2%   1.007µ ± 0%        ~ (p=0.117 n=10)
MatchBigEarly-8                 12.77n ± 4%   13.16n ± 3%   +3.09% (p=0.008 n=10)
MatchFold-8                     135.9n ± 0%   138.6n ± 2%   +1.99% (p=0.001 n=10)
MatchFoldBigLate-8              7.079µ ± 3%   6.920µ ± 2%   -2.25% (p=0.001 n=10)
MatchFoldBigEarly-8             6.087µ ± 3%   5.935µ ± 2%   -2.51% (p=0.001 n=10)
FindFold/Plain-8                18.41µ ± 1%   11.69µ ± 1%  -36.48% (p=0.000 n=10)
FindFold/BigLate-8              888.7µ ± 0%   882.3µ ± 1%   -0.72% (p=0.015 n=10)
FindFold/BigEarly-8             760.2µ ± 2%   753.0µ ± 1%   -0.95% (p=0.000 n=10)
RankMatch-8                     17.55n ± 0%   17.55n ± 2%        ~ (p=0.511 n=10)
RankMatchBigLate-8              1.010µ ± 2%   1.007µ ± 2%        ~ (p=0.925 n=10)
RankMatchBigEarly-8             1.229µ ± 3%   1.228µ ± 0%        ~ (p=0.306 n=10)
LevenshteinDistance-8           55.48n ± 4%   55.27n ± 2%        ~ (p=0.118 n=10)
LevenshteinDistanceBigLate-8    20.42µ ± 0%   20.52µ ± 5%   +0.45% (p=0.011 n=10)
LevenshteinDistanceBigEarly-8   20.42µ ± 3%   20.60µ ± 3%        ~ (p=0.102 n=10)
geomean                         1.814µ        1.763µ        -2.82%

                              │       a        │                   b                    │
                              │      B/op      │     B/op      vs base                  │
Match-8                           0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchBigLate-8                    0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchBigEarly-8                   0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchFold-8                       512.0 ± 0%       512.0 ± 0%        ~ (p=1.000 n=10) ¹
MatchFoldBigLate-8              8.750Ki ± 0%     8.750Ki ± 0%        ~ (p=1.000 n=10) ¹
MatchFoldBigEarly-8             8.750Ki ± 0%     8.750Ki ± 0%        ~ (p=1.000 n=10) ¹
FindFold/Plain-8                67.98Ki ± 0%     36.23Ki ± 0%  -46.70% (p=0.000 n=10)
FindFold/BigLate-8              1.098Mi ± 0%     1.067Mi ± 0%   -2.82% (p=0.000 n=10)
FindFold/BigEarly-8             1.098Mi ± 0%     1.067Mi ± 0%   -2.82% (p=0.000 n=10)
RankMatch-8                       0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
RankMatchBigLate-8                0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
RankMatchBigEarly-8               0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistance-8             0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistanceBigLate-8    6.375Ki ± 0%     6.375Ki ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistanceBigEarly-8   6.375Ki ± 0%     6.375Ki ± 0%        ~ (p=1.000 n=10) ¹
geomean                                      ²                  -4.47%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                              │       a       │                   b                   │
                              │   allocs/op   │  allocs/op   vs base                  │
Match-8                          0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchBigLate-8                   0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchBigEarly-8                  0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchFold-8                      2.000 ± 0%      2.000 ± 0%        ~ (p=1.000 n=10) ¹
MatchFoldBigLate-8               25.00 ± 0%      25.00 ± 0%        ~ (p=1.000 n=10) ¹
MatchFoldBigEarly-8              25.00 ± 0%      25.00 ± 0%        ~ (p=1.000 n=10) ¹
FindFold/Plain-8                 264.0 ± 0%      137.0 ± 0%  -48.11% (p=0.000 n=10)
FindFold/BigLate-8              3.208k ± 0%     3.081k ± 0%   -3.96% (p=0.000 n=10)
FindFold/BigEarly-8             3.208k ± 0%     3.081k ± 0%   -3.96% (p=0.000 n=10)
RankMatch-8                      0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
RankMatchBigLate-8               0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
RankMatchBigEarly-8              0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistance-8            0.000 ± 0%      0.000 ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistanceBigLate-8     1.000 ± 0%      1.000 ± 0%        ~ (p=1.000 n=10) ¹
LevenshteinDistanceBigEarly-8    1.000 ± 0%      1.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                     ²                 -4.79%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
@josharian
Copy link
Contributor Author

...and with that, I think I'm done playing with this codebase for now. :)

@lithammer
Copy link
Owner

...and with that, I think I'm done playing with this codebase for now. :)

It's been a pleasure 🙂

@lithammer lithammer merged commit 1701d62 into lithammer:master May 9, 2023
@lithammer
Copy link
Owner

All your fixes have been released as part of v1.1.8.

@josharian josharian deleted the transform-once branch May 15, 2023 16:37
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