mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Make the node graph use a document node's default type (#1965)
* Use document node default type * Refactor getting input * Clippy * Fix missing continue * Fix CI
This commit is contained in:
parent
507210b961
commit
514582fd8d
4 changed files with 278 additions and 191 deletions
|
@ -1,6 +1,5 @@
|
|||
use graph_craft::document::NodeNetwork;
|
||||
use graph_craft::graphene_compiler::Compiler;
|
||||
use graph_craft::proto::ProtoNetwork;
|
||||
#[cfg(any(feature = "criterion", feature = "iai"))]
|
||||
use graph_craft::{document::NodeNetwork, graphene_compiler::Compiler, proto::ProtoNetwork};
|
||||
|
||||
#[cfg(feature = "criterion")]
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
@ -8,11 +7,13 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|||
#[cfg(all(not(feature = "criterion"), feature = "iai"))]
|
||||
use iai_callgrind::{black_box, library_benchmark, library_benchmark_group, main};
|
||||
|
||||
#[cfg(any(feature = "criterion", feature = "iai"))]
|
||||
fn load_network(document_string: &str) -> NodeNetwork {
|
||||
let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document");
|
||||
serde_json::from_value::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document")
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "criterion", feature = "iai"))]
|
||||
fn compile(network: NodeNetwork) -> ProtoNetwork {
|
||||
let compiler = Compiler {};
|
||||
compiler.compile_single(network).unwrap()
|
||||
|
@ -41,6 +42,7 @@ fn compile_to_proto(c: &mut Criterion) {
|
|||
|
||||
#[cfg_attr(all(feature = "iai", not(feature = "criterion")), library_benchmark)]
|
||||
#[cfg_attr(all(feature = "iai", not(feature="criterion")), benches::with_setup(args = ["isometric-fountain", "painted-dreams", "procedural-string-lights", "red-dress", "valley-of-spires"], setup = load_from_name))]
|
||||
#[cfg(all(not(feature = "criterion"), feature = "iai"))]
|
||||
pub fn iai_compile_to_proto(input: NodeNetwork) {
|
||||
black_box(compile(input));
|
||||
}
|
||||
|
@ -56,3 +58,6 @@ library_benchmark_group!(name = compile_group; benchmarks = iai_compile_to_proto
|
|||
|
||||
#[cfg(all(not(feature = "criterion"), feature = "iai"))]
|
||||
main!(library_benchmark_groups = compile_group);
|
||||
|
||||
#[cfg(all(not(feature = "criterion"), not(feature = "iai")))]
|
||||
fn main() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue