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

Simplify encode_to_slice by using chunks_exact_mut #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mina86
Copy link

@mina86 mina86 commented Jul 19, 2023

Rather than using generate_iter to iterate over each 2-element chunks
of output buffer, use chunks_exact_mut. This removes the need for the
custom generate_iter function and makes the code shorter.

Criterian shows improvement but to be honest I don’t trust those
results (partially because also decoding showed improvements even
though I didn’t touch it):

hex_encode              time:   [79.268 µs 81.856 µs 84.279 µs]
                        change: [-15.070% -12.678% -10.255%] (p = 0.00 < 0.05)
                        Performance has improved.

rustc_hex_encode        time:   [36.926 µs 36.949 µs 36.971 µs]
                        change: [-3.3521% -3.2536% -3.1583%] (p = 0.00 < 0.05)
                        Performance has improved.

faster_hex_encode       time:   [820.07 ns 821.16 ns 822.52 ns]
                        change: [-3.7706% -3.4712% -3.1944%] (p = 0.00 < 0.05)
                        Performance has improved.

faster_hex_encode_fallback
                        time:   [11.554 µs 11.557 µs 11.562 µs]
                        change: [-2.8788% -2.8220% -2.7676%] (p = 0.00 < 0.05)
                        Performance has improved.

hex_decode              time:   [100.90 µs 100.98 µs 101.08 µs]
                        change: [-3.9865% -3.5655% -3.2365%] (p = 0.00 < 0.05)
                        Performance has improved.

rustc_hex_decode        time:   [65.759 µs 65.788 µs 65.819 µs]
                        change: [-2.1181% -1.9775% -1.8495%] (p = 0.00 < 0.05)
                        Performance has improved.

faster_hex_decode       time:   [2.2675 µs 2.2684 µs 2.2693 µs]
                        change: [-2.9682% -2.8188% -2.6234%] (p = 0.00 < 0.05)
                        Performance has improved.

faster_hex_decode_unchecked
                        time:   [928.35 ns 929.18 ns 930.05 ns]
                        change: [-0.5734% -0.4510% -0.3314%] (p = 0.00 < 0.05)
                        Change within noise threshold.

faster_hex_decode_fallback
                        time:   [11.416 µs 11.426 µs 11.438 µs]
                        change: [-3.8020% -3.6669% -3.5267%] (p = 0.00 < 0.05)
                        Performance has improved.

Rather than using generate_iter to iterate over each 2-element chunks
of output buffer, use chunks_exact_mut.  This removes the need for the
custom generate_iter function and makes the code shorter.

Criterian shows improvement but to be honest I don’t trust those
results (partially because also decoding showed improvements even
though I didn’t touch it):

    hex_encode              time:   [79.268 µs 81.856 µs 84.279 µs]
                            change: [-15.070% -12.678% -10.255%] (p = 0.00 < 0.05)
                            Performance has improved.

    rustc_hex_encode        time:   [36.926 µs 36.949 µs 36.971 µs]
                            change: [-3.3521% -3.2536% -3.1583%] (p = 0.00 < 0.05)
                            Performance has improved.

    faster_hex_encode       time:   [820.07 ns 821.16 ns 822.52 ns]
                            change: [-3.7706% -3.4712% -3.1944%] (p = 0.00 < 0.05)
                            Performance has improved.

    faster_hex_encode_fallback
                            time:   [11.554 µs 11.557 µs 11.562 µs]
                            change: [-2.8788% -2.8220% -2.7676%] (p = 0.00 < 0.05)
                            Performance has improved.

    hex_decode              time:   [100.90 µs 100.98 µs 101.08 µs]
                            change: [-3.9865% -3.5655% -3.2365%] (p = 0.00 < 0.05)
                            Performance has improved.

    rustc_hex_decode        time:   [65.759 µs 65.788 µs 65.819 µs]
                            change: [-2.1181% -1.9775% -1.8495%] (p = 0.00 < 0.05)
                            Performance has improved.

    faster_hex_decode       time:   [2.2675 µs 2.2684 µs 2.2693 µs]
                            change: [-2.9682% -2.8188% -2.6234%] (p = 0.00 < 0.05)
                            Performance has improved.

    faster_hex_decode_unchecked
                            time:   [928.35 ns 929.18 ns 930.05 ns]
                            change: [-0.5734% -0.4510% -0.3314%] (p = 0.00 < 0.05)
                            Change within noise threshold.

    faster_hex_decode_fallback
                            time:   [11.416 µs 11.426 µs 11.438 µs]
                            change: [-3.8020% -3.6669% -3.5267%] (p = 0.00 < 0.05)
                            Performance has improved.
@mina86
Copy link
Author

mina86 commented Nov 11, 2023

@KokaKiwi, friendly ping.

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.

None yet

1 participant