delete ancient benchmarks

This commit is contained in:
Ralf Jung 2022-07-04 15:11:14 -04:00
parent 709e29a167
commit 25cbfcc5be
10 changed files with 0 additions and 181 deletions

View file

@ -1,26 +0,0 @@
#![feature(test, rustc_private)]
extern crate test;
use crate::test::Bencher;
mod helpers;
use crate::helpers::*;
#[bench]
fn fib(bencher: &mut Bencher) {
bencher.iter(fibonacci_helper::main)
}
#[bench]
fn fib_miri(bencher: &mut Bencher) {
miri_helper::run("fibonacci_helper", bencher);
}
#[bench]
fn fib_iter(bencher: &mut Bencher) {
bencher.iter(fibonacci_helper_iterative::main)
}
#[bench]
fn fib_iter_miri(bencher: &mut Bencher) {
miri_helper::run("fibonacci_helper_iterative", bencher);
}

View file

@ -1,8 +0,0 @@
#[inline(never)]
pub fn main() {
assert_eq!(fib(10), 55);
}
fn fib(n: usize) -> usize {
if n <= 2 { 1 } else { fib(n - 1) + fib(n - 2) }
}

View file

@ -1,15 +0,0 @@
#[inline(never)]
pub fn main() {
assert_eq!(fib(10), 55);
}
fn fib(n: usize) -> usize {
let mut a = 0;
let mut b = 1;
for _ in 0..n {
let c = a;
a = b;
b += c;
}
a
}

View file

@ -1,59 +0,0 @@
extern crate rustc_driver;
extern crate rustc_hir;
extern crate rustc_interface;
use rustc_driver::Compilation;
use rustc_interface::{interface, Queries};
use crate::test::Bencher;
struct MiriCompilerCalls<'a> {
bencher: &'a mut Bencher,
}
impl rustc_driver::Callbacks for MiriCompilerCalls<'_> {
fn after_analysis<'tcx>(
&mut self,
compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
compiler.session().abort_if_errors();
queries.global_ctxt().unwrap().peek_mut().enter(|tcx| {
let (entry_def_id, entry_type) =
tcx.entry_fn(()).expect("no main or start function found");
self.bencher.iter(|| {
let config = miri::MiriConfig::default();
miri::eval_entry(tcx, entry_def_id, entry_type, config);
});
});
compiler.session().abort_if_errors();
Compilation::Stop
}
}
fn find_sysroot() -> String {
// Taken from https://github.com/Manishearth/rust-clippy/pull/911.
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
match (home, toolchain) {
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
_ =>
option_env!("RUST_SYSROOT")
.expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
.to_owned(),
}
}
pub fn run(filename: &str, bencher: &mut Bencher) {
let args = &[
"miri".to_string(),
format!("benches/helpers/{}.rs", filename),
"--sysroot".to_string(),
find_sysroot(),
];
rustc_driver::RunCompiler::new(args, &mut MiriCompilerCalls { bencher }).run().unwrap()
}

View file

@ -1,7 +0,0 @@
// This module gets included in multiple crates, and they each only use part of it.
#![allow(dead_code)]
pub mod fibonacci_helper;
pub mod fibonacci_helper_iterative;
pub mod miri_helper;
pub mod smoke_helper;

View file

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

View file

@ -1,9 +0,0 @@
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);
}

View file

@ -1,2 +0,0 @@
#[inline(never)]
pub fn main() {}

View file

@ -1,16 +0,0 @@
#![feature(test, rustc_private)]
extern crate test;
use crate::test::Bencher;
mod helpers;
use crate::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);
}

View file

@ -1,35 +0,0 @@
#![feature(test, rustc_private)]
extern crate test;
use crate::test::Bencher;
mod helpers;
use crate::helpers::*;
#[bench]
fn noop(bencher: &mut Bencher) {
bencher.iter(smoke_helper::main)
}
/*
// really slow
#[bench]
fn noop_miri_full(bencher: &mut Bencher) {
let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
bencher.iter(|| {
let mut process = std::process::Command::new("target/release/miri");
process.arg("benches/smoke_helper.rs")
.arg("--sysroot").arg(&path);
let output = process.output().unwrap();
if !output.status.success() {
println!("{}", String::from_utf8(output.stdout).unwrap());
println!("{}", String::from_utf8(output.stderr).unwrap());
panic!("failed to run miri");
}
})
}
*/
#[bench]
fn noop_miri_interpreter(bencher: &mut Bencher) {
miri_helper::run("smoke_helper", bencher);
}