]> git.lizzy.rs Git - rust.git/blobdiff - benches/smoke.rs
fmt: set force_multiline_blocks=true
[rust.git] / benches / smoke.rs
index 992f435a501ce1ba508568a7fd8dfbebda9b4586..9229e972d7f3ba9f492aef10a01aeec9ff5e39cf 100644 (file)
@@ -1,28 +1,13 @@
-#![feature(custom_attribute, test)]
-#![feature(rustc_private)]
-#![allow(unused_attributes)]
-
-extern crate getopts;
-extern crate miri;
-extern crate rustc;
-extern crate rustc_driver;
-
-use miri::interpreter;
-use rustc::session::Session;
-use rustc_driver::{driver, CompilerCalls};
-use std::cell::RefCell;
-use std::rc::Rc;
+#![feature(test, rustc_private)]
 
 extern crate test;
-use test::Bencher;
-
-mod smoke_helper;
+use crate::test::Bencher;
+mod helpers;
+use crate::helpers::*;
 
 #[bench]
 fn noop(bencher: &mut Bencher) {
-    bencher.iter(|| {
-        smoke_helper::main();
-    })
+    bencher.iter(|| smoke_helper::main())
 }
 
 /*
@@ -46,31 +31,5 @@ fn noop_miri_full(bencher: &mut Bencher) {
 
 #[bench]
 fn noop_miri_interpreter(bencher: &mut Bencher) {
-    let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
-    rustc_driver::run_compiler(&[
-        "miri".to_string(), "benches/smoke_helper.rs".to_string(), "--sysroot".to_string(), path.to_string(),
-    ], &mut MiriCompilerCalls(Rc::new(RefCell::new(bencher))));
-}
-
-struct MiriCompilerCalls<'a>(Rc<RefCell<&'a mut Bencher>>);
-
-impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
-    fn build_controller(
-        &mut self,
-        _: &Session,
-        _: &getopts::Matches
-    ) -> driver::CompileController<'a> {
-        let mut control: driver::CompileController<'a> = driver::CompileController::basic();
-
-        let bencher = self.0.clone();
-
-        control.after_analysis.callback = Box::new(move |state| {
-            state.session.abort_if_errors();
-            bencher.borrow_mut().iter(|| {
-                interpreter::interpret_start_points(state.tcx.unwrap(), state.mir_map.unwrap());
-            })
-        });
-
-        control
-    }
+    miri_helper::run("smoke_helper", bencher);
 }