1 //! Support code for rustc's built in unit-test and micro-benchmarking
4 //! Almost all user code will only be interested in `Bencher` and
5 //! `black_box`. All other interactions (such as writing tests and
6 //! benchmarks themselves) should be done via the `#[test]` and
7 //! `#[bench]` attributes.
9 //! See the [Testing Chapter](../book/ch11-00-testing.html) of the book for more details.
11 #![crate_name = "test"]
12 #![unstable(feature = "test", issue = "27812")]
13 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
14 test(attr(deny(warnings))))]
16 #![feature(staged_api)]
21 // FIXME: we should be more explicit about the exact APIs that we
24 assert_test_result, filter_tests, parse_opts, run_test, test_main, test_main_static,
25 Bencher, DynTestFn, DynTestName, Metric, MetricMap, Options, RunIgnored, ShouldPanic,
26 StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, TestDescAndFn, TestName, TestOpts,
27 TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk, stats::Summary
30 pub use std::hint::black_box;
35 use libtest::stats::Stats;
38 pub fn sum_three_items(b: &mut Bencher) {
40 [1e20f64, 1.5f64, -1e20f64].sum();
45 pub fn sum_many_f64(b: &mut Bencher) {
46 let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60];
47 let v = (0..500).map(|i| nums[i % 5]).collect::<Vec<_>>();
54 pub fn no_iter(_: &mut Bencher) {}