This adds benchmarks for the bitfield implementation.
Compares the performance of getters and setters generated by the macro with the performance of a handwritten and hard coded implementation for the same spec.
Useful
To learn how to generate macro code in a way that the compiler is able to heavily optimize it later.
For beginners to understand how to manipulate data on a bit level.
Note
Feel free to adjust the implementation in later commits to make it opt-in testable.
Benchmarks
Below some benchmarks comparing the hand-written implementation of this PR with the macro-generated implementation of the bitfield implementation in my fork. The performance of both seem to be similar.
test generated::get_a ... bench: 99 ns/iter (+/- 4)
test generated::get_b ... bench: 98 ns/iter (+/- 4)
test generated::get_c ... bench: 98 ns/iter (+/- 14)
test generated::get_d ... bench: 97 ns/iter (+/- 2)
test generated::get_e ... bench: 99 ns/iter (+/- 2)
test generated::set_a ... bench: 481 ns/iter (+/- 19)
test generated::set_b ... bench: 627 ns/iter (+/- 37)
test generated::set_c ... bench: 507 ns/iter (+/- 35)
test generated::set_d ... bench: 622 ns/iter (+/- 24)
test generated::set_e ... bench: 459 ns/iter (+/- 16)
test handwritten::get_a ... bench: 99 ns/iter (+/- 3)
test handwritten::get_b ... bench: 102 ns/iter (+/- 14)
test handwritten::get_c ... bench: 102 ns/iter (+/- 8)
test handwritten::get_d ... bench: 100 ns/iter (+/- 20)
test handwritten::get_e ... bench: 98 ns/iter (+/- 6)
test handwritten::set_a ... bench: 582 ns/iter (+/- 20)
test handwritten::set_b ... bench: 614 ns/iter (+/- 35)
test handwritten::set_c ... bench: 533 ns/iter (+/- 18)
test handwritten::set_d ... bench: 606 ns/iter (+/- 21)
test handwritten::set_e ... bench: 456 ns/iter (+/- 21)
This adds benchmarks for the
bitfield
implementation.Compares the performance of getters and setters generated by the macro with the performance of a handwritten and hard coded implementation for the same spec.
Useful
Note
Benchmarks
Below some benchmarks comparing the hand-written implementation of this PR with the macro-generated implementation of the
bitfield
implementation in my fork. The performance of both seem to be similar.