mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
use criterion::BenchmarkGroup;
|
|
use criterion::measurement::Measurement;
|
|
use graph_craft::proto::ProtoNetwork;
|
|
use graph_craft::util::{DEMO_ART, compile, load_from_name};
|
|
use graphene_std::application_io::EditorApi;
|
|
use interpreted_executor::dynamic_executor::DynamicExecutor;
|
|
use interpreted_executor::util::wrap_network_in_scope;
|
|
|
|
pub fn setup_network(name: &str) -> (DynamicExecutor, ProtoNetwork) {
|
|
let network = load_from_name(name);
|
|
let editor_api = std::sync::Arc::new(EditorApi::default());
|
|
let mut network = wrap_network_in_scope(network, editor_api);
|
|
let preprocessor = preprocessor::Preprocessor::new();
|
|
preprocessor.preprocess(&mut network, &|_| None).unwrap();
|
|
let proto_network = compile(network, &interpreted_executor::node_registry::NODE_REGISTRY);
|
|
let executor = DynamicExecutor::new(proto_network.clone()).unwrap();
|
|
(executor, proto_network)
|
|
}
|
|
|
|
// Some benches in this module's include set drive the demos themselves.
|
|
#[allow(dead_code)]
|
|
pub fn bench_for_each_demo<M: Measurement, F>(group: &mut BenchmarkGroup<M>, f: F)
|
|
where
|
|
F: Fn(&str, &mut BenchmarkGroup<M>),
|
|
{
|
|
for name in DEMO_ART {
|
|
f(name, group);
|
|
}
|
|
}
|