sharksforarms / deku

Declarative binary reading and writing: bit-level, symmetric, serialization/deserialization
Apache License 2.0
1.15k stars 55 forks source link

Constify primitive bit size of types #279

Closed wcampbell0x2a closed 2 years ago

wcampbell0x2a commented 2 years ago

The following are from benchmarks vs the current master. The checked_mul is removed, as we can't currently panic in const.

deku_read_byte          time:   [5.8110 ns 5.9354 ns 6.0773 ns]
                        change: [-14.417% -10.955% -7.2630%] (p = 0.00 < 0.05)

deku_write_byte         time:   [46.900 ns 47.660 ns 48.633 ns]
                        change: [-12.747% -9.1856% -5.6869%] (p = 0.00 < 0.05)

deku_read_bits          time:   [364.10 ns 368.39 ns 372.98 ns]
                        change: [-1.5093% +0.5970% +2.8900%] (p = 0.59 > 0.05)

deku_write_bits         time:   [73.628 ns 74.842 ns 76.069 ns]
                        change: [-11.619% -9.2405% -6.9498%] (p = 0.00 < 0.05)

deku_read_enum          time:   [10.270 ns 10.528 ns 10.809 ns]
                        change: [-13.440% -10.368% -7.1636%] (p = 0.00 < 0.05)

deku_write_enum         time:   [75.269 ns 76.175 ns 77.083 ns]
                        change: [-11.316% -9.0440% -6.3322%] (p = 0.00 < 0.05)

deku_read_vec           time:   [506.90 ns 516.85 ns 527.33 ns]
                        change: [-18.733% -16.265% -13.612%] (p = 0.00 < 0.05)

deku_write_vec          time:   [3.0721 µs 3.0974 µs 3.1234 µs]
                        change: [-16.929% -15.820% -14.695%] (p = 0.00 < 0.05)

deku_read_vec_perf      time:   [485.14 ns 494.13 ns 503.52 ns]
                        change: [-11.852% -8.3565% -4.9234%] (p = 0.00 < 0.05)

deku_write_vec_perf     time:   [3.3761 µs 3.4090 µs 3.4442 µs]
                        change: [-14.783% -12.624% -10.196%] (p = 0.00 < 0.05)