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

uint256: optimize and add benchmark for Set #153

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

AaronChen0
Copy link
Contributor

Not sure why shallow copy is slow in golang, but changing shallow copy to direct value copy boosts Set from 2 ns to 0.22 ns.

Running

go test ./...

returns

ok  	github.com/holiman/uint256	0.975s

Benchmark

goos: linux
goarch: amd64
pkg: github.com/holiman/uint256
cpu: AMD Ryzen 7 7735H with Radeon Graphics         
                      │     old      │                 new                  │
                      │    sec/op    │    sec/op     vs base                │
Set/single/uint256-16   2.0205n ± 1%   0.2160n ± 2%  -89.31% (p=0.000 n=10)
Set/single/big-16        2.908n ± 1%    2.925n ± 2%        ~ (p=0.516 n=10)
geomean                  2.424n        0.7950n       -67.20%

                      │     old      │                 new                 │
                      │     B/op     │    B/op     vs base                 │
Set/single/uint256-16   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Set/single/big-16       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                            ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                      │     old      │                 new                 │
                      │  allocs/op   │ allocs/op   vs base                 │
Set/single/uint256-16   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Set/single/big-16       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                            ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c9fc0ce) to head (2a98ce6).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #153   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines         1642      1642           
=========================================
  Hits          1642      1642           

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 a6658c5 into holiman:master Apr 16, 2024
5 checks passed
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