Skip to content

Commit

Permalink
Prepare the bitvec! fix for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrlyn committed Sep 16, 2019
1 parent 56e228d commit e62f0ac
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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/
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[package]
name = "bitvec"
version = "0.15.1"
version = "0.15.2"
authors = [
"myrrlyn <[email protected]>",
]
Expand Down
31 changes: 31 additions & 0 deletions benches/macros.rs
Original file line number Diff line number Diff line change
@@ -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]);
}

0 comments on commit e62f0ac

Please sign in to comment.