]> git.lizzy.rs Git - rust.git/commitdiff
seperate and move miscellaneous benchmarks to librustc
authorNiv Kaminer <nivkner@zoho.com>
Wed, 4 Oct 2017 12:21:15 +0000 (12:21 +0000)
committerNiv Kaminer <nivkner@zoho.com>
Wed, 4 Oct 2017 12:21:15 +0000 (12:21 +0000)
src/libcore/benches/mem.rs [deleted file]
src/librustc/benches/dispatch.rs [new file with mode: 0644]
src/librustc/benches/lib.rs [new file with mode: 0644]
src/librustc/benches/match.rs [new file with mode: 0644]

diff --git a/src/libcore/benches/mem.rs b/src/libcore/benches/mem.rs
deleted file mode 100644 (file)
index 6f5afa9..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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;
-
-// Completely miscellaneous language-construct benchmarks.
-// 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()
-    });
-}
-
-// 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/dispatch.rs b/src/librustc/benches/dispatch.rs
new file mode 100644 (file)
index 0000000..63e7477
--- /dev/null
@@ -0,0 +1,44 @@
+// 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;
+
+// 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()
+    });
+}
diff --git a/src/librustc/benches/lib.rs b/src/librustc/benches/lib.rs
new file mode 100644 (file)
index 0000000..98e1d92
--- /dev/null
@@ -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 (file)
index 0000000..638b1ce
--- /dev/null
@@ -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,
+        }
+    });
+}