1
Fork 0

fix benchmarks and add benchmarks for repeat expressions

This commit is contained in:
Oliver Schneider 2016-11-17 16:01:30 +01:00
parent fd6a90860c
commit b10c53031a
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
4 changed files with 35 additions and 6 deletions

View file

@ -33,7 +33,7 @@ pub fn run(filename: &str, bencher: &mut Bencher) {
find_sysroot()
];
let compiler_calls = &mut MiriCompilerCalls(Rc::new(RefCell::new(bencher)));
rustc_driver::run_compiler(args, compiler_calls);
rustc_driver::run_compiler(args, compiler_calls, None, None);
}
impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
@ -51,13 +51,15 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
state.session.abort_if_errors();
let tcx = state.tcx.unwrap();
let mir_map = state.mir_map.unwrap();
let (node_id, _) = state.session.entry_fn.borrow()
let (entry_node_id, _) = state.session.entry_fn.borrow()
.expect("no main or start function found");
let entry_def_id = tcx.map.local_def_id(entry_node_id);
let mut mir_map = MirMap { map: mir_map.map.clone() };
run_mir_passes(tcx, &mut mir_map);
bencher.borrow_mut().iter(|| { eval_main(tcx, &mir_map, node_id); });
run_mir_passes(tcx);
let memory_size = 100*1024*1024; // 100MB
let step_limit = 1000_000;
let stack_limit = 100;
bencher.borrow_mut().iter(|| { eval_main(tcx, entry_def_id, memory_size, step_limit, stack_limit); });
state.session.abort_if_errors();
});

View file

@ -0,0 +1,4 @@
fn main() {
let data: [u8; 1024] = [42; 1024];
assert_eq!(data.len(), 1024);
}

View file

@ -0,0 +1,7 @@
fn main() {
let mut data: [u8; 1024] = unsafe { std::mem::uninitialized() };
for i in 0..data.len() {
unsafe { std::ptr::write(&mut data[i], 0); }
}
assert_eq!(data.len(), 1024);
}

16
benches/repeat.rs Normal file
View file

@ -0,0 +1,16 @@
#![feature(test, rustc_private)]
extern crate test;
use test::Bencher;
mod helpers;
use helpers::*;
#[bench]
fn repeat(bencher: &mut Bencher) {
miri_helper::run("repeat", bencher);
}
#[bench]
fn repeat_manual(bencher: &mut Bencher) {
miri_helper::run("repeat_manual", bencher);
}