Initial import of bencher v0.1.5

Test: n/a
Change-Id: I53222b48d3c04c9c7b630f06beba26e459125c68
diff --git a/macros.rs b/macros.rs
new file mode 100644
index 0000000..7685029
--- /dev/null
+++ b/macros.rs
@@ -0,0 +1,55 @@
+
+/// Defines a function called `$group_name` that returns the test description
+/// values for the listed functions `$function`.
+#[macro_export]
+macro_rules! benchmark_group {
+    ($group_name:ident, $($function:path),+) => {
+        pub fn $group_name() -> ::std::vec::Vec<$crate::TestDescAndFn> {
+            use $crate::{TestDescAndFn, TestFn, TestDesc};
+            use std::borrow::Cow;
+            let mut benches = ::std::vec::Vec::new();
+            $(
+                benches.push(TestDescAndFn {
+                    desc: TestDesc {
+                        name: Cow::from(stringify!($function)),
+                        ignore: false,
+                    },
+                    testfn: TestFn::StaticBenchFn($function),
+                });
+            )+
+            benches
+        }
+    };
+    ($group_name:ident, $($function:path,)+) => {
+        benchmark_group!($group_name, $($function),+);
+    };
+}
+
+
+/// Define a `fn main()` that will run all benchmarks defined by the groups
+/// in `$group_name`.
+///
+/// The main function will read the first argument from the console and use
+/// it to filter the benchmarks to run.
+#[macro_export]
+macro_rules! benchmark_main {
+    ($($group_name:path),+) => {
+        fn main() {
+            use $crate::TestOpts;
+            use $crate::run_tests_console;
+            let mut test_opts = TestOpts::default();
+            // check to see if we should filter:
+            if let Some(arg) = ::std::env::args().skip(1).find(|arg| *arg != "--bench") {
+                test_opts.filter = Some(arg);
+            }
+            let mut benches = Vec::new();
+            $(
+                benches.extend($group_name());
+            )+
+            run_tests_console(&test_opts, benches).unwrap();
+        }
+    };
+    ($($group_name:path,)+) => {
+        benchmark_main!($($group_name),+);
+    };
+}