Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ./x.py bench again #66659

Merged
merged 1 commit into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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