diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-12-29 16:16:18 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-12-29 16:17:50 +0100 |
| commit | 75d8339cdd8c5b07982764a9b78952a67b7cd519 (patch) | |
| tree | 4f0f05fa415f71e9597602efb2c99e5dacb50d9e | |
| parent | 6211dd7250e9b8e80733f74911ca88c661adb1a9 (diff) | |
| download | rust-75d8339cdd8c5b07982764a9b78952a67b7cd519.tar.gz rust-75d8339cdd8c5b07982764a9b78952a67b7cd519.zip | |
Replace TDynBenchFn with Fn(&mut Bencher)
| -rw-r--r-- | library/test/src/lib.rs | 10 | ||||
| -rw-r--r-- | library/test/src/types.rs | 7 |
2 files changed, 5 insertions, 12 deletions
diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 2516f3452b1..17e15243afd 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -444,8 +444,8 @@ pub fn convert_benchmarks_to_tests(tests: Vec<TestDescAndFn>) -> Vec<TestDescAnd .into_iter() .map(|x| { let testfn = match x.testfn { - DynBenchFn(bench) => DynTestFn(Box::new(move || { - bench::run_once(|b| __rust_begin_short_backtrace(|| bench.run(b))) + DynBenchFn(benchfn) => DynTestFn(Box::new(move || { + bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b))) })), StaticBenchFn(benchfn) => DynTestFn(Box::new(move || { bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b))) @@ -544,11 +544,9 @@ pub fn run_test( TestRunOpts { strategy, nocapture: opts.nocapture, concurrency, time: opts.time_options }; match testfn { - DynBenchFn(bencher) => { + DynBenchFn(benchfn) => { // Benchmarks aren't expected to panic, so we run them all in-process. - crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, |harness| { - bencher.run(harness) - }); + crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, benchfn); None } StaticBenchFn(benchfn) => { diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 3512a57e8e4..37bb38fb0df 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -74,11 +74,6 @@ impl fmt::Display for TestName { } } -/// Represents a benchmark function. -pub trait TDynBenchFn: Send { - fn run(&self, harness: &mut Bencher); -} - // A function that runs a test. If the function returns successfully, // the test succeeds; if the function panics then the test fails. We // may need to come up with a more clever definition of test in order @@ -87,7 +82,7 @@ pub enum TestFn { StaticTestFn(fn()), StaticBenchFn(fn(&mut Bencher)), DynTestFn(Box<dyn FnOnce() + Send>), - DynBenchFn(Box<dyn TDynBenchFn + 'static>), + DynBenchFn(Box<dyn Fn(&mut Bencher) + Send>), } impl TestFn { |
