Add .travis.yml. Bench closures return values. Feature gate.

This commit is contained in:
Nipunn Koorapati
2016-08-27 19:45:49 -07:00
parent abf82ff533
commit 951f1d0bea
3 changed files with 20 additions and 3 deletions
+5
View File
@@ -3,5 +3,10 @@ rust:
- nightly
- beta
- stable
script: |
cargo build --verbose &&
cargo test --verbose &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --features benchmarks) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose --features benchmarks bench)
notifications:
webhooks: http://build.servo.org:54856/travis
+3
View File
@@ -13,3 +13,6 @@ documentation = "http://doc.servo.org/smallvec/"
name = "smallvec"
path = "lib.rs"
doctest = false
[features]
benchmarks = []
+12 -3
View File
@@ -5,7 +5,7 @@
//! Small vectors in various sizes. These store a certain number of elements inline and fall back
//! to the heap for larger allocations.
#![feature(test)]
#![cfg_attr(feature = "benchmarks", feature(test))]
use std::borrow::{Borrow, BorrowMut};
use std::cmp;
@@ -649,10 +649,8 @@ impl_array!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 24, 32,
#[cfg(test)]
pub mod tests {
extern crate test;
use SmallVec;
use std::borrow::ToOwned;
use self::test::Bencher;
// We heap allocate all these strings so that double frees will show up under valgrind.
@@ -1004,6 +1002,13 @@ pub mod tests {
assert_eq!(vec.clone().into_iter().len(), 3);
assert_eq!(vec.drain().len(), 3);
}
}
#[cfg(all(feature = "benchmarks", test))]
mod bench {
extern crate test;
use SmallVec;
use self::test::Bencher;
#[bench]
fn bench_push(b: &mut Bencher) {
@@ -1012,6 +1017,7 @@ pub mod tests {
for x in 0..100 {
vec.push(x);
}
vec
});
}
@@ -1022,6 +1028,7 @@ pub mod tests {
for x in 0..100 {
vec.insert(0, x);
}
vec
});
}
@@ -1030,6 +1037,7 @@ pub mod tests {
b.iter(|| {
let mut vec: SmallVec<[u64; 16]> = SmallVec::new();
vec.extend(0..100);
vec
});
}
@@ -1041,6 +1049,7 @@ pub mod tests {
vec.push(x);
vec.pop();
}
vec
});
}
}