mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 13:28:11 +08:00
Exclude executor teardown from the measured bench regions
This commit is contained in:
@@ -12,9 +12,9 @@ fn run_once(c: &mut Criterion) {
|
|||||||
bench_for_each_demo(&mut group, |name, g| {
|
bench_for_each_demo(&mut group, |name, g| {
|
||||||
let (_, network) = setup_network(name);
|
let (_, network) = setup_network(name);
|
||||||
g.bench_function(name, |b| {
|
g.bench_function(name, |b| {
|
||||||
b.iter_batched(
|
b.iter_batched_ref(
|
||||||
|| DynamicExecutor::new(network.clone()).unwrap(),
|
|| DynamicExecutor::new(network.clone()).unwrap(),
|
||||||
|executor| Executor::execute(&&executor, std::hint::black_box(context)).unwrap(),
|
|executor| Executor::execute(&&*executor, std::hint::black_box(context)).unwrap(),
|
||||||
criterion::BatchSize::LargeInput,
|
criterion::BatchSize::LargeInput,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ fn setup_run_once(name: &str) -> DynamicExecutor {
|
|||||||
|
|
||||||
#[library_benchmark]
|
#[library_benchmark]
|
||||||
#[benches::with_setup(args = ["isometric-fountain", "painted-dreams", "procedural-string-lights", "parametric-dunescape", "red-dress", "valley-of-spires"], setup = setup_run_once)]
|
#[benches::with_setup(args = ["isometric-fountain", "painted-dreams", "procedural-string-lights", "parametric-dunescape", "red-dress", "valley-of-spires"], setup = setup_run_once)]
|
||||||
pub fn run_once(executor: DynamicExecutor) -> DynamicExecutor {
|
pub fn run_once(executor: DynamicExecutor) -> (DynamicExecutor, core_types::gpoll::GPoll<graph_craft::document::value::TaggedValue>) {
|
||||||
let context = application_io::RenderConfig::default();
|
let context = application_io::RenderConfig::default();
|
||||||
black_box(Executor::execute(&&executor, black_box(context)).unwrap());
|
let result = black_box(Executor::execute(&&executor, black_box(context)).unwrap());
|
||||||
|
|
||||||
// Return the executor so its teardown happens outside the measured section
|
// Return the executor and result so their teardown happens outside the measured section
|
||||||
executor
|
(executor, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
library_benchmark_group!(name = run_once_group; benchmarks = run_once);
|
library_benchmark_group!(name = run_once_group; benchmarks = run_once);
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ fn update_executor(c: &mut Criterion) {
|
|||||||
let mut group = c.benchmark_group("Update Executor");
|
let mut group = c.benchmark_group("Update Executor");
|
||||||
bench_for_each_demo(&mut group, |name, g| {
|
bench_for_each_demo(&mut group, |name, g| {
|
||||||
g.bench_function(name, |b| {
|
g.bench_function(name, |b| {
|
||||||
b.iter_batched(
|
b.iter_batched_ref(
|
||||||
|| {
|
|| {
|
||||||
let (_, proto_network) = setup_network(name);
|
let (_, proto_network) = setup_network(name);
|
||||||
let empty = ProtoNetwork::default();
|
let empty = ProtoNetwork::default();
|
||||||
let executor = DynamicExecutor::new(empty).unwrap();
|
let executor = DynamicExecutor::new(empty).unwrap();
|
||||||
(executor, proto_network)
|
(executor, proto_network)
|
||||||
},
|
},
|
||||||
|(mut executor, network)| executor.update(std::hint::black_box(network)),
|
|(executor, network)| executor.update(std::hint::black_box(std::mem::take(network))),
|
||||||
criterion::BatchSize::SmallInput,
|
criterion::BatchSize::SmallInput,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user