Skip to content

Commit

Permalink
Attempt at some improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear committed Apr 7, 2021
1 parent b2a91f8 commit e91277f
Show file tree
Hide file tree
Showing 3 changed files with 496 additions and 6 deletions.
50 changes: 50 additions & 0 deletions benches/bench_idl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,56 @@ fn bench_duplex(c: &mut Criterion) {

let i = Duplex(vec1, vec2);
do_bench_duplex(c, "11_ludwig_sparse", i);

let mut vec1 = Vec::new();
for i in 1..300 {
vec1.push(64 * i + 5);
vec1.push(64 * i + 7);
vec1.push(64 * i + 15);
vec1.push(64 * i + 20);
vec1.push(64 * i + 25);
}
let mut vec2 = Vec::new();
for i in 200..500 {
vec2.push(64 * i + 5);
vec2.push(64 * i + 7);
vec2.push(64 * i + 15);
vec2.push(64 * i + 20);
vec2.push(64 * i + 25);
}

let i = Duplex(vec1, vec2);
do_bench_duplex(c, "12_ludwig_sparse", i);

let mut vec1 = Vec::new();
for i in 1..300 {
vec1.push(64 * i + 5);
vec1.push(64 * i + 7);
vec1.push(64 * i + 15);
vec1.push(64 * i + 20);
vec1.push(64 * i + 25);
vec1.push(64 * i + 30);
vec1.push(64 * i + 35);
vec1.push(64 * i + 40);
vec1.push(64 * i + 45);
vec1.push(64 * i + 50);
}
let mut vec2 = Vec::new();
for i in 200..500 {
vec2.push(64 * i + 5);
vec2.push(64 * i + 7);
vec2.push(64 * i + 15);
vec2.push(64 * i + 20);
vec2.push(64 * i + 25);
vec1.push(64 * i + 30);
vec1.push(64 * i + 35);
vec1.push(64 * i + 40);
vec1.push(64 * i + 45);
vec1.push(64 * i + 50);
}

let i = Duplex(vec1, vec2);
do_bench_duplex(c, "13_ludwig_sparse", i);
}

fn do_bench_triplex(c: &mut Criterion, label: &str, i: Triplex) {
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ extern crate serde_derive;

#[cfg(feature = "use_smallvec")]
extern crate smallvec;

pub mod v2;

#[cfg(feature = "use_smallvec")]
use smallvec::SmallVec;

Expand Down Expand Up @@ -74,7 +77,6 @@ impl PartialOrd for IDLRange {
impl PartialEq for IDLRange {
fn eq(&self, other: &Self) -> bool {
self.range == other.range
// && self.mask == other.mask
}
}

Expand Down Expand Up @@ -819,17 +821,13 @@ impl fmt::Debug for IDLBitRange {

#[cfg(test)]
mod tests {
// use test::Bencher;
use super::{AndNot, IDLBitRange};
use std::iter::FromIterator;

#[test]
fn test_store_zero() {
let idl_a = IDLBitRange::from_iter(vec![0]);
let idl_b = IDLBitRange::from_iter(vec![0, 1, 2]);
// FIXME: Implement a "contains" function.
println!("{:?}", idl_a);
println!("{:?}", idl_b);
assert!(idl_a.contains(0));
}

#[test]
Expand Down
Loading

0 comments on commit e91277f

Please sign in to comment.