提交 59257e6e 编写于 作者: M Mazdak Farrokhzad

make `./x.py bench` again

上级 a449535b
......@@ -35,7 +35,7 @@ fn $mac(b: &mut Bencher) {
.iter()
.cycle()
.take(5_000)
.filter_map(|s| <($t)>::from_str(s).ok())
.filter_map(|s| <$t>::from_str(s).ok())
.max()
})
}
......@@ -51,7 +51,7 @@ fn $mac(b: &mut Bencher) {
.iter()
.cycle()
.take(5_000)
.filter_map(|s| <($t)>::from_str_radix(s, $radix).ok())
.filter_map(|s| <$t>::from_str_radix(s, $radix).ok())
.max()
})
}
......
use test::Bencher;
// Static/dynamic method dispatch
struct Struct {
field: isize
}
trait Trait {
fn method(&self) -> isize;
}
impl Trait for Struct {
fn method(&self) -> isize {
self.field
}
}
#[bench]
fn trait_vtable_method_call(b: &mut Bencher) {
let s = Struct { field: 10 };
let t = &s as &Trait;
b.iter(|| {
t.method()
});
}
#[bench]
fn trait_static_method_call(b: &mut Bencher) {
let s = Struct { field: 10 };
b.iter(|| {
s.method()
});
}
#![feature(slice_patterns)]
#![feature(test)]
extern crate test;
mod dispatch;
mod pattern;
use test::Bencher;
// Static/dynamic method dispatch
struct Struct {
field: isize
}
trait Trait {
fn method(&self) -> isize;
}
impl Trait for Struct {
fn method(&self) -> isize {
self.field
}
}
#[bench]
fn trait_vtable_method_call(b: &mut Bencher) {
let s = Struct { field: 10 };
let t = &s as &dyn Trait;
b.iter(|| {
t.method()
});
}
#[bench]
fn trait_static_method_call(b: &mut Bencher) {
let s = Struct { field: 10 };
b.iter(|| {
s.method()
});
}
// Overhead of various match forms
#[bench]
fn option_some(b: &mut Bencher) {
let x = Some(10);
b.iter(|| {
match x {
Some(y) => y,
None => 11
}
});
}
#[bench]
fn vec_pattern(b: &mut Bencher) {
let x = [1,2,3,4,5,6];
b.iter(|| {
match x {
[1,2,3,..] => 10,
_ => 11,
}
});
}
use test::Bencher;
// Overhead of various match forms
#[bench]
fn option_some(b: &mut Bencher) {
let x = Some(10);
b.iter(|| {
match x {
Some(y) => y,
None => 11
}
});
}
#[bench]
fn vec_pattern(b: &mut Bencher) {
let x = [1,2,3,4,5,6];
b.iter(|| {
match x {
[1,2,3,..] => 10,
_ => 11,
}
});
}
......@@ -52,7 +52,7 @@ fn test_minimize2() {
fn test_rpath_relative() {
if cfg!(target_os = "macos") {
let config = &mut RPathConfig {
used_crates: Vec::new(),
used_crates: &[],
has_rpath: true,
is_like_osx: true,
linker_is_gnu: false,
......@@ -64,7 +64,7 @@ fn test_rpath_relative() {
assert_eq!(res, "@loader_path/../lib");
} else {
let config = &mut RPathConfig {
used_crates: Vec::new(),
used_crates: &[],
out_filename: PathBuf::from("bin/rustc"),
get_install_prefix_lib_path: &mut || panic!(),
has_rpath: true,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册