Skip to content

feat: Add new trait DynProgress & type BoxedDynProgress #22

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

Merged
merged 3 commits into from
Sep 4, 2023
Merged
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
31 changes: 24 additions & 7 deletions benches/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use criterion::*;
use prodash::{
messages::MessageLevel,
tree::{root::Options as TreeOptions, Root as Tree},
BoxedDynProgress,
};

fn usage(c: &mut Criterion) {
Expand All @@ -13,15 +14,20 @@ fn usage(c: &mut Criterion) {
.create()
.into()
}
c.benchmark_group("Tree::add_child")
.throughput(Throughput::Elements(4))
.bench_function("add children to build a tree of tasks and clear them (in drop)", |b| {
c.benchmark_group("BoxedDynProgress::set")
.throughput(Throughput::Elements(5))
.bench_function("set tree 5 times", |b| {
let root = small_tree();
let mut progress = root.add_child("the one");
progress.init(Some(20), Some("element".into()));
let mut progress = BoxedDynProgress::new(progress);
use prodash::Progress;
b.iter(|| {
let mut c = root.add_child("1");
let _one = c.add_child("1");
let _two = c.add_child("2");
let _three = c.add_child("3");
progress.set(1);
progress.set(2);
progress.set(3);
progress.set(4);
progress.set(5);
});
});
c.benchmark_group("tree::Item::set")
Expand All @@ -38,6 +44,17 @@ fn usage(c: &mut Criterion) {
progress.set(5);
});
});
c.benchmark_group("Tree::add_child")
.throughput(Throughput::Elements(4))
.bench_function("add children to build a tree of tasks and clear them (in drop)", |b| {
let root = small_tree();
b.iter(|| {
let mut c = root.add_child("1");
let _one = c.add_child("1");
let _two = c.add_child("2");
let _three = c.add_child("3");
});
});
c.benchmark_group("tree::Item::message")
.throughput(Throughput::Elements(1))
.bench_function(
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub mod messages;
pub mod progress;

mod traits;
pub use traits::{Progress, RawProgress, Root, WeakRoot};
pub use traits::{BoxedDynProgress, DynProgress, DynProgressToProgressBridge, Progress, RawProgress, Root, WeakRoot};

mod throughput;
pub use crate::throughput::Throughput;
Expand Down
Loading