From 51542a9192b9fc9279b5fde337b52a5050ebbc39 Mon Sep 17 00:00:00 2001 From: Niv Kaminer Date: Wed, 4 Oct 2017 12:21:15 +0000 Subject: [PATCH] seperate and move miscellaneous benchmarks to librustc --- .../mem.rs => librustc/benches/dispatch.rs} | 25 ------------- src/librustc/benches/lib.rs | 19 ++++++++++ src/librustc/benches/match.rs | 35 +++++++++++++++++++ 3 files changed, 54 insertions(+), 25 deletions(-) rename src/{libcore/benches/mem.rs => librustc/benches/dispatch.rs} (68%) create mode 100644 src/librustc/benches/lib.rs create mode 100644 src/librustc/benches/match.rs diff --git a/src/libcore/benches/mem.rs b/src/librustc/benches/dispatch.rs similarity index 68% rename from src/libcore/benches/mem.rs rename to 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 or the MIT license +// , 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 or the MIT license +// , 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, + } + }); +} -- 2.44.0