Skip to content

Conversation

@taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Jul 18, 2021

This change makes decoding about 10x faster than the current implementation, on my machine.

Before:

hex_decode              time:   [128.28 us 129.41 us 130.70 us]

After:

hex_decode              time:   [12.206 us 12.242 us 12.284 us]                        
Benchmarks per commit

Current main branch (aa8f300)

hex_decode              time:   [128.28 us 129.41 us 130.70 us]

First commit of this PR: Use lookup table for decoding (870590e)

hex_decode              time:   [63.538 us 63.936 us 64.419 us]
                        change: [-50.833% -50.462% -50.088%] (p = 0.00 < 0.05)
                        Performance has improved.

Second commit of this PR: Inline val function (3b75b32)

hex_decode              time:   [32.263 us 32.382 us 32.521 us]
                        change: [-49.441% -49.098% -48.682%] (p = 0.00 < 0.05)
                        Performance has improved.

Third commit of this PR: Use chunks_exact instead of chunks (ff1d115)

hex_decode              time:   [24.701 us 24.814 us 24.936 us]
                        change: [-24.459% -23.911% -23.395%] (p = 0.00 < 0.05)
                        Performance has improved.

Fourth commit of this PR: Use decode_to_slice in Vec::from_hex (4fd0ed8)

hex_decode              time:   [16.060 us 16.297 us 16.608 us]
                        change: [-35.137% -34.468% -33.556%] (p = 0.00 < 0.05)
                        Performance has improved.

Fifth commit of this PR: Inline decode_to_slice function (3e2aa25)

hex_decode              time:   [12.206 us 12.242 us 12.284 us]                        
                        change: [-21.954% -20.254% -18.150%] (p = 0.00 < 0.05)
                        Performance has improved.

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2021

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Contributor

@Luro02 Luro02 left a comment

Choose a reason for hiding this comment

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

Looks good :)

KokaKiwi and others added 4 commits November 9, 2025 00:31
- Remove unused `u8` import from `core` module
- Add lint allow annotation for `__` constant to suppress non_upper_case_globals warning
- Refactor `decode_in_slice()` to use slice-based `val()` function for cleaner implementation
@KokaKiwi KokaKiwi merged commit 76f37c7 into KokaKiwi:main Nov 9, 2025
33 of 34 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.

4 participants