Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): re-architecturing tellur_core #13

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 3 additions & 54 deletions tellur_core/benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,61 +1,10 @@
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());
})
});
}
pub mod std_logical_and;

criterion_group!(
benches,
plan_wrapped_not,
run_wrapped_not,
plan_or_with_andnot,
run_or_with_andnot
std_logical_and::std_logical_and_full,
std_logical_and::std_logical_and_evaluation
);
criterion_main!(benches);
92 changes: 0 additions & 92 deletions tellur_core/benches/or_with_andnot.rs

This file was deleted.

57 changes: 57 additions & 0 deletions tellur_core/benches/std_logical_and.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use criterion::Criterion;
use tellur_core::container::types::bool::{Bool, BoolValue};
use tellur_core::container::types::{TellurShape, TellurValue, TellurValueBox};
use tellur_core::libstd::logical::and::AndNodePlanned;
use tellur_core::node::plan::TellurNodePlanned;

pub fn std_logical_and_full(c: &mut Criterion) {
c.bench_function("std::logical::and Full", |b| {
b.iter(|| {
let memory = [Bool.null(), Bool.null(), Bool.null()];
let parameters: Vec<&TellurValueBox> = vec![&memory[0], &memory[1]];
let returns: Vec<&TellurValueBox> = vec![&memory[2]];

unsafe {
let BoolValue(l) = BoolValue::downcast_mut_unchecked(&memory[0]);
let BoolValue(r) = BoolValue::downcast_mut_unchecked(&memory[1]);
*l = true;
*r = false;
}

unsafe {
AndNodePlanned.evaluate(parameters, returns).unwrap();
}

let BoolValue(result) = unsafe { BoolValue::downcast_ref_unchecked(&memory[2]) };

let _ = *result;
});
});
}

pub fn std_logical_and_evaluation(c: &mut Criterion) {
c.bench_function("std::logical::and Evaluation Only", |b| {
let memory = [Bool.null(), Bool.null(), Bool.null()];
let parameters: Vec<&TellurValueBox> = vec![&memory[0], &memory[1]];
let returns: Vec<&TellurValueBox> = vec![&memory[2]];

unsafe {
let BoolValue(l) = BoolValue::downcast_mut_unchecked(&memory[0]);
let BoolValue(r) = BoolValue::downcast_mut_unchecked(&memory[1]);
*l = true;
*r = false;
}

unsafe {
b.iter(|| {
AndNodePlanned
.evaluate(parameters.clone(), returns.clone())
.unwrap();
});
}

let BoolValue(result) = unsafe { BoolValue::downcast_ref_unchecked(&memory[2]) };

let _ = *result;
});
}
36 changes: 0 additions & 36 deletions tellur_core/benches/wrapped_not.rs

This file was deleted.

Loading