Skip to content

Conversation

@fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Jul 5, 2021

We can do it with a single comparison. The speed up for the bad case is ~30%.

name                   old time/op    new time/op    delta
_Cmp/single/big-8        13.1ns ± 4%    13.1ns ± 2%     ~     (p=0.887 n=10+9)
_Cmp/single/uint256-8    5.40ns ± 3%    4.69ns ± 3%  -13.17%  (p=0.000 n=10+9)

name                   old alloc/op   new alloc/op   delta
_Cmp/single/big-8         0.00B          0.00B          ~     (all equal)
_Cmp/single/uint256-8     0.00B          0.00B          ~     (all equal)

name                   old allocs/op  new allocs/op  delta
_Cmp/single/big-8          0.00           0.00          ~     (all equal)
_Cmp/single/uint256-8      0.00           0.00          ~     (all equal)

fyrchik and others added 2 commits July 5, 2021 14:00
We should check for both `a < b` and `a > b` cases
to get more realistic results.

Signed-off-by: Evgenii Stratonikov <[email protected]>
In case when first argument is greater or equal then the second
we will perform 2 comparisons. This commit implements `Cmp` using only 1.
@fyrchik
Copy link
Contributor Author

fyrchik commented Jul 5, 2021

I am not sure if this is the right way to change benchmark (we get duration of 2 operations), but it seems simpler than making 2 more benchmarks.

Copy link
Owner

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@holiman holiman merged commit 792909f into holiman:master Jul 5, 2021
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