vec.rs 371 B

12345678910111213141516171819202122
  1. #![feature(test)]
  2. #[global_allocator]
  3. static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
  4. extern crate ralloc;
  5. extern crate test;
  6. #[bench]
  7. fn bench_vec(b: &mut test::Bencher) {
  8. b.iter(|| {
  9. let mut stuff = Vec::with_capacity(10);
  10. for i in 0..10000 {
  11. stuff.push(i)
  12. }
  13. stuff.reserve(100000);
  14. stuff
  15. });
  16. }