-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: introduce criterion (benchmark) (#9)
- Loading branch information
Showing
11 changed files
with
954 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
description = "Development environment for tellur"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/release-24.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
rust-overlay.url = "github:oxalica/rust-overlay"; | ||
}; | ||
|
||
outputs = { nixpkgs, flake-utils, rust-overlay, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
overlays = [ (import rust-overlay) ]; | ||
pkgs = import nixpkgs { | ||
inherit system overlays; | ||
}; | ||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; | ||
in | ||
{ | ||
devShells.default = pkgs.stdenv.mkDerivation { | ||
name = "tellur-dev"; | ||
nativeBuildInputs = with pkgs; [ | ||
pkg-config | ||
gnuplot | ||
] ++ [ | ||
toolchain | ||
]; | ||
buildInputs = with pkgs; [ | ||
openssl | ||
libiconv | ||
] ++ lib.optionals stdenvNoCC.isDarwin [ | ||
darwin.Security | ||
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration | ||
]; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
mod or_with_andnot; | ||
mod wrapped_not; | ||
|
||
use criterion::{criterion_group, criterion_main}; | ||
use tellur_core::node::TellurNode; | ||
use tellur_core::types::TellurTypedValueContainer; | ||
|
||
use self::or_with_andnot::or_with_andnot_tree; | ||
use self::wrapped_not::wrapped_not_tree; | ||
|
||
fn plan_wrapped_not(c: &mut criterion::Criterion) { | ||
c.bench_function("Planning Not-Wrapped Tree", |b| { | ||
b.iter(|| { | ||
let tree = wrapped_not_tree(); | ||
let _ = tree.planned(); | ||
}) | ||
}); | ||
} | ||
|
||
fn run_wrapped_not(c: &mut criterion::Criterion) { | ||
let planned = wrapped_not_tree().planned(); | ||
let vec = vec![TellurTypedValueContainer::new( | ||
tellur_core::types::TellurTypedValue::Bool(true).into(), | ||
)]; | ||
c.bench_function("Running Not-Wrapped Tree", |b| { | ||
b.iter(|| { | ||
let _ = planned.evaluate(vec.clone()); | ||
}) | ||
}); | ||
} | ||
|
||
fn plan_or_with_andnot(c: &mut criterion::Criterion) { | ||
c.bench_function("Planning Or-With-Andnot Tree", |b| { | ||
b.iter(|| { | ||
let tree = or_with_andnot_tree(); | ||
let _ = tree.planned(); | ||
}) | ||
}); | ||
} | ||
|
||
fn run_or_with_andnot(c: &mut criterion::Criterion) { | ||
let planned = or_with_andnot_tree().planned(); | ||
let vec = vec![ | ||
TellurTypedValueContainer::new(tellur_core::types::TellurTypedValue::Bool(true).into()), | ||
TellurTypedValueContainer::new(tellur_core::types::TellurTypedValue::Bool(false).into()), | ||
]; | ||
c.bench_function("Running Or-With-Andnot Tree", |b| { | ||
b.iter(|| { | ||
let _ = planned.evaluate(vec.clone()); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
plan_wrapped_not, | ||
run_wrapped_not, | ||
plan_or_with_andnot, | ||
run_or_with_andnot | ||
); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
use std::collections::BTreeMap; | ||
|
||
use tellur_core::node::TellurNode; | ||
use tellur_core::tellur_std_node::logical::and::AndNode; | ||
use tellur_core::tellur_std_node::logical::not::NotNode; | ||
use tellur_core::tree::{NodeId, TellurNodeTree, TreeInput}; | ||
use tellur_core::types::{TellurRefType, TellurType}; | ||
|
||
pub fn or_with_andnot_tree() -> TellurNodeTree { | ||
TellurNodeTree { | ||
name: "or".to_string(), | ||
parameters: BTreeMap::from([ | ||
( | ||
"left".to_string(), | ||
(TellurRefType::Immutable, TellurType::Bool), | ||
), | ||
( | ||
"right".to_string(), | ||
(TellurRefType::Immutable, TellurType::Bool), | ||
), | ||
]), | ||
returns: BTreeMap::from([("result".to_string(), TellurType::Bool)]), | ||
nodes: BTreeMap::from([ | ||
( | ||
NodeId(0), | ||
( | ||
BTreeMap::from([( | ||
"value".to_string(), | ||
TreeInput::Parameter { | ||
name: "left".to_string(), | ||
}, | ||
)]), | ||
Box::new(NotNode {}) as Box<dyn TellurNode>, | ||
), | ||
), | ||
( | ||
NodeId(1), | ||
( | ||
BTreeMap::from([( | ||
"value".to_string(), | ||
TreeInput::Parameter { | ||
name: "right".to_string(), | ||
}, | ||
)]), | ||
Box::new(NotNode {}) as Box<dyn TellurNode>, | ||
), | ||
), | ||
( | ||
NodeId(2), | ||
( | ||
BTreeMap::from([ | ||
( | ||
"left".to_string(), | ||
TreeInput::NodeOutput { | ||
id: NodeId(0), | ||
output_name: "result".to_string(), | ||
}, | ||
), | ||
( | ||
"right".to_string(), | ||
TreeInput::NodeOutput { | ||
id: NodeId(1), | ||
output_name: "result".to_string(), | ||
}, | ||
), | ||
]), | ||
Box::new(AndNode {}) as Box<dyn TellurNode>, | ||
), | ||
), | ||
( | ||
NodeId(3), | ||
( | ||
BTreeMap::from([( | ||
"value".to_string(), | ||
TreeInput::NodeOutput { | ||
id: NodeId(2), | ||
output_name: "result".to_string(), | ||
}, | ||
)]), | ||
Box::new(NotNode {}) as Box<dyn TellurNode>, | ||
), | ||
), | ||
]), | ||
outputs: BTreeMap::from([( | ||
"result".to_string(), | ||
TreeInput::NodeOutput { | ||
id: NodeId(3), | ||
output_name: "result".to_string(), | ||
}, | ||
)]), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::collections::BTreeMap; | ||
|
||
use tellur_core::node::TellurNode; | ||
use tellur_core::tellur_std_node::logical::not::NotNode; | ||
use tellur_core::tree::{NodeId, TellurNodeTree, TreeInput}; | ||
use tellur_core::types::{TellurRefType, TellurType}; | ||
|
||
pub fn wrapped_not_tree() -> TellurNodeTree { | ||
TellurNodeTree { | ||
name: "not_wrapped".to_string(), | ||
parameters: BTreeMap::from([( | ||
"value".to_string(), | ||
(TellurRefType::Immutable, TellurType::Bool), | ||
)]), | ||
returns: BTreeMap::from([("result".to_string(), TellurType::Bool)]), | ||
nodes: BTreeMap::from([( | ||
NodeId(0), | ||
( | ||
BTreeMap::from([( | ||
"value".to_string(), | ||
TreeInput::Parameter { | ||
name: "value".to_string(), | ||
}, | ||
)]), | ||
Box::new(NotNode {}) as Box<dyn TellurNode>, | ||
), | ||
)]), | ||
outputs: BTreeMap::from([( | ||
"result".to_string(), | ||
TreeInput::NodeOutput { | ||
id: NodeId(0), | ||
output_name: "result".to_string(), | ||
}, | ||
)]), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.