eddieantonio / binary-to-hex-simd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hx

Convert binary to ASCII hexadecimal strings.

This was a coding exercise for me to learn cargo bench and how to write inline assembly in Rust.

Originally, it was for me to learn how to use Rust's portable SIMD module, but I ended up writing inline assembly instead ¯\_(ツ)_/¯

Writing Rust portable SIMD sure is easy! Same energy

Performance

Here are the benchmarks on my M1 Macbook (note: I am not diligent about keeping a quiet machine). Each test was run on 12 MiB of input:

Implementation Average time per iteration Stddev Throughput
byte_by_byte 14,855,262 ns ±306,213 ns 0.79 GiB/s
portable_simd 3,385,895 ns ±122,011 ns 3.46 GiB/s
neon_tbl 1,876,648 ns ±81,677 ns 6.24 GiB/s

The absolute best performance I got was 1,794,971 nanoseconds to convert 12 MiB of data to ASCII hexadecimal, or a rate of 6.53 GiB/second. I don't have precise enough equipment to measure bytes converted per clock cycle. I am, after all, benchmarking on my laptop, on battery power, so take these results with a grain of salt.

License

Copyright © 2023 Eddie Antonio Santos. GPLv3 licensed.

About

License:GNU General Public License v3.0


Languages

Language:Rust 100.0%