Skip to content

Commit

Permalink
make ./x.py bench again
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Nov 23, 2019
1 parent a449535 commit 59257e6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/libcore/benches/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ macro_rules! from_str_bench {
.iter()
.cycle()
.take(5_000)
.filter_map(|s| <($t)>::from_str(s).ok())
.filter_map(|s| <$t>::from_str(s).ok())
.max()
})
}
Expand All @@ -51,7 +51,7 @@ macro_rules! from_str_radix_bench {
.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()
})
}
Expand Down
34 changes: 0 additions & 34 deletions src/librustc/benches/dispatch.rs

This file was deleted.

61 changes: 59 additions & 2 deletions src/librustc/benches/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,63 @@
#![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,
}
});
}
25 changes: 0 additions & 25 deletions src/librustc/benches/pattern.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/rpath/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 59257e6

Please sign in to comment.