diff options
| author | Niv Kaminer <nivkner@zoho.com> | 2017-10-04 12:21:15 +0000 |
|---|---|---|
| committer | Niv Kaminer <nivkner@zoho.com> | 2017-10-04 12:21:15 +0000 |
| commit | 51542a9192b9fc9279b5fde337b52a5050ebbc39 (patch) | |
| tree | f7badba8733ae31e5eeb66b7ceb5dab9a588afae | |
| parent | 5eebab28dd45954ef09237a56c2c0b97684040d3 (diff) | |
| download | rust-51542a9192b9fc9279b5fde337b52a5050ebbc39.tar.gz | |
seperate and move miscellaneous benchmarks to librustc
| -rw-r--r-- | src/librustc/benches/dispatch.rs (renamed from src/libcore/benches/mem.rs) | 25 | ||||
| -rw-r--r-- | src/librustc/benches/lib.rs | 19 | ||||
| -rw-r--r-- | src/librustc/benches/match.rs | 35 |
3 files changed, 54 insertions, 25 deletions
diff --git a/src/libcore/benches/mem.rs b/src/librustc/benches/dispatch.rs index 6f5afa9ba99..63e74778fb9 100644 --- a/src/libcore/benches/mem.rs +++ b/src/librustc/benches/dispatch.rs @@ -10,7 +10,6 @@ use test::Bencher; -// Completely miscellaneous language-construct benchmarks. // Static/dynamic method dispatch struct Struct { @@ -43,27 +42,3 @@ fn trait_static_method_call(b: &mut Bencher) { s.method() }); } - -// Overhead of various match forms - -#[bench] -fn match_option_some(b: &mut Bencher) { - let x = Some(10); - b.iter(|| { - match x { - Some(y) => y, - None => 11 - } - }); -} - -#[bench] -fn match_vec_pattern(b: &mut Bencher) { - let x = [1,2,3,4,5,6]; - b.iter(|| { - match x { - [1,2,3,..] => 10, - _ => 11, - } - }); -} diff --git a/src/librustc/benches/lib.rs b/src/librustc/benches/lib.rs new file mode 100644 index 00000000000..98e1d92127b --- /dev/null +++ b/src/librustc/benches/lib.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(warnings)] + +#![feature(slice_patterns)] +#![feature(test)] + +extern crate test; + +mod dispatch; +mod match; diff --git a/src/librustc/benches/match.rs b/src/librustc/benches/match.rs new file mode 100644 index 00000000000..638b1ce3f75 --- /dev/null +++ b/src/librustc/benches/match.rs @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +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, + } + }); +} |
