mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
* Borrow the input in LazyInput::eval, as Node::eval does * Allow wrapping a network in scope without the render node * Implement CacheHash for BTreeMap * Replace the CanvasFrame render output with canvas info on the response * Add OwnedContextImpl::with_varargs for a context with several varargs
40 lines
1.6 KiB
Rust
40 lines
1.6 KiB
Rust
use criterion::BenchmarkGroup;
|
|
use criterion::measurement::Measurement;
|
|
use graph_craft::proto::ProtoNetwork;
|
|
use graph_craft::util::{DEMO_ART, compile};
|
|
use graphene_std::application_io::EditorApi;
|
|
use graphene_std::runtime::{AsyncRuntime, Spawn, Task};
|
|
use interpreted_executor::dynamic_executor::{DynamicExecutor, OutputHandle};
|
|
use interpreted_executor::util::wrap_network_with_render_node_in_scope;
|
|
use std::path::Path;
|
|
|
|
pub fn setup_network(name: &str) -> (DynamicExecutor, OutputHandle, ProtoNetwork) {
|
|
let network = futures::executor::block_on(document_loader::open_document(Path::new(&format!("../../demo-artwork/{name}.graphite"))))
|
|
.unwrap()
|
|
.network;
|
|
let editor_api = std::sync::Arc::new(EditorApi::default());
|
|
let mut network = wrap_network_with_render_node_in_scope(network, editor_api, AsyncRuntime::new(std::sync::Arc::new(DummySpawner)).handle());
|
|
let preprocessor = preprocessor::Preprocessor::new();
|
|
preprocessor.preprocess(&mut network, &|_| None).unwrap();
|
|
let proto_network = compile(network);
|
|
let mut executor = DynamicExecutor::default();
|
|
let (output, _) = executor.update(proto_network.clone()).unwrap();
|
|
(executor, output, proto_network)
|
|
}
|
|
|
|
#[allow(dead_code, reason = "shared by the bench targets, only some of which call it, and each compiles this module separately")]
|
|
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);
|
|
}
|
|
}
|
|
|
|
// TODO: Consider replacing this with a real spawner and benchmarking async nodes
|
|
struct DummySpawner;
|
|
impl Spawn for DummySpawner {
|
|
fn spawn(&self, _task: Task) {}
|
|
}
|