Skip to content

Commit 75d8339

Browse files
committed
Replace TDynBenchFn with Fn(&mut Bencher)
1 parent 6211dd7 commit 75d8339

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

library/test/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ pub fn convert_benchmarks_to_tests(tests: Vec<TestDescAndFn>) -> Vec<TestDescAnd
444444
.into_iter()
445445
.map(|x| {
446446
let testfn = match x.testfn {
447-
DynBenchFn(bench) => DynTestFn(Box::new(move || {
448-
bench::run_once(|b| __rust_begin_short_backtrace(|| bench.run(b)))
447+
DynBenchFn(benchfn) => DynTestFn(Box::new(move || {
448+
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
449449
})),
450450
StaticBenchFn(benchfn) => DynTestFn(Box::new(move || {
451451
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
@@ -544,11 +544,9 @@ pub fn run_test(
544544
TestRunOpts { strategy, nocapture: opts.nocapture, concurrency, time: opts.time_options };
545545

546546
match testfn {
547-
DynBenchFn(bencher) => {
547+
DynBenchFn(benchfn) => {
548548
// Benchmarks aren't expected to panic, so we run them all in-process.
549-
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, |harness| {
550-
bencher.run(harness)
551-
});
549+
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, benchfn);
552550
None
553551
}
554552
StaticBenchFn(benchfn) => {

library/test/src/types.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ impl fmt::Display for TestName {
7474
}
7575
}
7676

77-
/// Represents a benchmark function.
78-
pub trait TDynBenchFn: Send {
79-
fn run(&self, harness: &mut Bencher);
80-
}
81-
8277
// A function that runs a test. If the function returns successfully,
8378
// the test succeeds; if the function panics then the test fails. We
8479
// may need to come up with a more clever definition of test in order
@@ -87,7 +82,7 @@ pub enum TestFn {
8782
StaticTestFn(fn()),
8883
StaticBenchFn(fn(&mut Bencher)),
8984
DynTestFn(Box<dyn FnOnce() + Send>),
90-
DynBenchFn(Box<dyn TDynBenchFn + 'static>),
85+
DynBenchFn(Box<dyn Fn(&mut Bencher) + Send>),
9186
}
9287

9388
impl TestFn {

0 commit comments

Comments
 (0)