Skip to content

Commit

Permalink
chore: Extend profiler
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Feb 7, 2025
1 parent 706c6ac commit 0f72d5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions profiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = ["."]
[dependencies]
dhat = "*"
jsonschema = { path = "../crates/jsonschema/" }
referencing = { path = "../crates/jsonschema-referencing" }
pico-args = "0.5"
serde_json = "1"

Expand Down
12 changes: 11 additions & 1 deletion profiler/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use referencing::{Draft, Registry};
use serde_json::Value;
use std::fs;

Expand Down Expand Up @@ -29,6 +30,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let validator = jsonschema::validator_for(&schema)?;

let input_resources = vec![(
"http://example.com/schema",
Draft::Draft202012.create_resource(schema.clone()),
)];

#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();
for _ in 0..args.iterations {
Expand All @@ -46,8 +52,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"apply" => {
let _ = validator.apply(&instance).basic();
}
"registry" => {
let _ = Registry::try_from_resources(input_resources.into_iter());
break;
}
_ => panic!(
"Invalid method. Use 'build', 'is_valid', 'validate', 'iter_errors`, or 'apply'"
"Invalid method. Use 'registry', 'build', 'is_valid', 'validate', 'iter_errors`, or 'apply'"
),
}
}
Expand Down

0 comments on commit 0f72d5c

Please sign in to comment.