diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a1ca99e..cceec18f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes will be documented in this file. This document is written according to the [Keep a Changelog][kac] style. +## 0.15.2 + +### Changed + +The `bitvec![bit; rep]` construction macro has its implementation rewritten to +be much faster. This fault was reported by GitHub user [@caelunshun] in +[Issue #28]. + ## 0.15.1 ### Removed @@ -465,6 +473,7 @@ Initial implementation and release. - `bitvec!` generator macro [@GeorgeGkas]: https://github.com/GeorgeGkas +[@caelunshun]: https://github.com/caelunshun [@geq1t]: https://github.com/geq1t [@koushiro]: https://github.com/koushiro [@overminder]: https://github.com/overminder @@ -478,5 +487,6 @@ Initial implementation and release. [Issue #12]: https://github.com/myrrlyn/bitvec/issues/12 [Issue #15]: https://github.com/myrrlyn/bitvec/issues/15 [Issue #16]: https://github.com/myrrlyn/bitvec/issues/16 +[Issue #28]: https://github.com/myrrlyn/bitvec/issues/28 [`Sync`]: https://doc.rust-lang.org/stable/core/marker/trait.Sync.html [kac]: https://keepachangelog.com/en/1.0.0/ diff --git a/Cargo.toml b/Cargo.toml index 8468f633..b448e290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ [package] name = "bitvec" -version = "0.15.1" +version = "0.15.2" authors = [ "myrrlyn ", ] diff --git a/benches/macros.rs b/benches/macros.rs new file mode 100644 index 00000000..6b8c262e --- /dev/null +++ b/benches/macros.rs @@ -0,0 +1,31 @@ +/*! Macro construction benchmarks. + +This is taken from [issue #28], which noted that the `bitvec![bit; rep]` +expansion was horribly inefficient. + +This benchmark crate should be used for all macro performance recording, and +compare the macros against `vec!`. While `vec!` will always be faster, because +`bitvec!` does more work than `vec!`, they should at least be close. + +Original performance was 10,000x slower. Performance after the fix for #28 was +within 20ns. + +[issue #28]: https://github.com/myrrlyn/bitvec/issues/28 +!*/ + +#![feature(test)] + +extern crate test; + +use test::Bencher; +use bitvec::prelude::*; + +#[bench] +fn bitvec_init(b: &mut Bencher) { + b.iter(|| bitvec![0; 16 * 16 * 9]); +} + +#[bench] +fn vec_init(b: &mut Bencher) { + b.iter(|| vec![0u8; 16 * 16 * 9 / 8]); +}