Skip to content

Commit 5e21df7

Browse files
committed
Merge branch 'simplify'
2 parents abcc61b + 6c60835 commit 5e21df7

File tree

13 files changed

+586
-438
lines changed

13 files changed

+586
-438
lines changed

CHANGELOG.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,62 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
This release is all about making `dyn` possible both for nested progress, as well as for 'simple' one (previously known as `RawProgress`).
11+
Switching to this release naturally makes it possible for users of `Progress` to also use `dyn Progress`, as this trait is now object safe (formerly `RawProgress`).
12+
If there are compile errors, the code now needs `NestedProgress`, instead of `Progress`, and possibly the import of the `Count` trait.
13+
Finally, it's recommended to review all usages of `Progress` as they can possibly be replaced with `Count` which provides the guarantee that only counting happens,
14+
and no change of the progress information itself.
15+
16+
### New Features (BREAKING)
17+
18+
- <csr-id-6aba6e34f3e39bba5e609a0bc780c758cb43c821/> split `Progress` into various super-traits to allow most of them to be dyn-safe.
19+
`Progress` is now `NestedProgress`, `RawProgress` is now `Progress`, and there is
20+
a new `Count` trait for solely counting things.
21+
22+
### Commit Statistics
23+
24+
<csr-read-only-do-not-edit/>
25+
26+
- 5 commits contributed to the release.
27+
- 13 days passed between releases.
28+
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
29+
- 0 issues like '(#ID)' were seen in commit messages
30+
31+
### Commit Details
32+
33+
<csr-read-only-do-not-edit/>
34+
35+
<details><summary>view details</summary>
36+
37+
* **Uncategorized**
38+
- Fixup nested dyn-traits ([`5e76abf`](https://github.com/byron/prodash/commit/5e76abfbf8dc18afddea68873c50cce677450a54))
39+
- Merge branch 'feat/dyn-progress' into simplify ([`c1590e4`](https://github.com/byron/prodash/commit/c1590e4650a9ffcf96a216f6a9fe82a1cf7cc10e))
40+
- Split `Progress` into various super-traits to allow most of them to be dyn-safe. ([`6aba6e3`](https://github.com/byron/prodash/commit/6aba6e34f3e39bba5e609a0bc780c758cb43c821))
41+
- Add benchmarks for dyn-traits ([`9d03124`](https://github.com/byron/prodash/commit/9d03124667935314a9d4c8e52886b994967f2671))
42+
- Refactor ([`54094b6`](https://github.com/byron/prodash/commit/54094b63289446f0582c6b49a666b5d993625dff))
43+
</details>
44+
845
## 25.0.2 (2023-08-22)
946

47+
<csr-id-05741765491984487beea7326eff9863b669ab51/>
48+
1049
### Chore
1150

1251
- <csr-id-05741765491984487beea7326eff9863b669ab51/> Adjusting changelogs prior to release of prodash v25.0.2
1352

53+
### New Features
54+
55+
- <csr-id-24d0b2aaa58978990fea90c2f3b387e238acf966/> Add new trait `DynProgress` & type `BoxedDynProgress`
56+
1457
### Commit Statistics
1558

1659
<csr-read-only-do-not-edit/>
1760

18-
- 2 commits contributed to the release.
61+
- 4 commits contributed to the release over the course of 2 calendar days.
1962
- 37 days passed between releases.
20-
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
63+
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
2164
- 0 issues like '(#ID)' were seen in commit messages
2265

2366
### Commit Details
@@ -27,8 +70,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2770
<details><summary>view details</summary>
2871

2972
* **Uncategorized**
73+
- Release prodash v25.0.2 ([`abcc61b`](https://github.com/byron/prodash/commit/abcc61b456e75d4f700f3c476849d7c36c3ece15))
3074
- Adjusting changelogs prior to release of prodash v25.0.2 ([`0574176`](https://github.com/byron/prodash/commit/05741765491984487beea7326eff9863b669ab51))
3175
- Remove `atty` in favor of `is-terminal` ([`2bfe9ad`](https://github.com/byron/prodash/commit/2bfe9adca357cf48d7310036684eeb85efa5ef46))
76+
- Add new trait `DynProgress` & type `BoxedDynProgress` ([`24d0b2a`](https://github.com/byron/prodash/commit/24d0b2aaa58978990fea90c2f3b387e238acf966))
3277
</details>
3378

3479
## 25.0.1 (2023-07-16)

benches/usage.rs

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use criterion::*;
22
use prodash::{
33
messages::MessageLevel,
44
tree::{root::Options as TreeOptions, Root as Tree},
5+
BoxedDynNestedProgress, Count,
56
};
7+
use std::sync::atomic::Ordering;
68

79
fn usage(c: &mut Criterion) {
810
fn small_tree() -> std::sync::Arc<Tree> {
@@ -13,38 +15,106 @@ fn usage(c: &mut Criterion) {
1315
.create()
1416
.into()
1517
}
16-
c.benchmark_group("Tree::add_child")
17-
.throughput(Throughput::Elements(4))
18-
.bench_function("add children to build a tree of tasks and clear them (in drop)", |b| {
18+
c.benchmark_group("Shared Counter")
19+
.throughput(Throughput::Elements(5))
20+
.bench_function("inc counter 5 times", |b| {
1921
let root = small_tree();
22+
let progress = root.add_child("the one");
23+
progress.init(Some(20), Some("element".into()));
24+
let counter = progress.counter();
2025
b.iter(|| {
21-
let mut c = root.add_child("1");
22-
let _one = c.add_child("1");
23-
let _two = c.add_child("2");
24-
let _three = c.add_child("3");
26+
counter.fetch_add(1, Ordering::Relaxed);
27+
counter.fetch_add(1, Ordering::Relaxed);
28+
counter.fetch_add(1, Ordering::Relaxed);
29+
counter.fetch_add(1, Ordering::Relaxed);
30+
counter.fetch_add(1, Ordering::Relaxed);
31+
});
32+
})
33+
.bench_function("set counter 5 times", |b| {
34+
let root = small_tree();
35+
let progress = root.add_child("the one");
36+
progress.init(Some(20), Some("element".into()));
37+
let counter = progress.counter();
38+
b.iter(|| {
39+
counter.store(1, Ordering::SeqCst);
40+
counter.store(2, Ordering::SeqCst);
41+
counter.store(3, Ordering::SeqCst);
42+
counter.store(4, Ordering::SeqCst);
43+
counter.store(5, Ordering::SeqCst);
2544
});
2645
});
27-
c.benchmark_group("tree::Item::set")
46+
c.benchmark_group("BoxedDynProgress")
2847
.throughput(Throughput::Elements(5))
2948
.bench_function("set tree 5 times", |b| {
3049
let root = small_tree();
31-
let mut progress = root.add_child("the one");
50+
let progress = root.add_child("the one");
3251
progress.init(Some(20), Some("element".into()));
52+
let progress = BoxedDynNestedProgress::new(progress);
3353
b.iter(|| {
3454
progress.set(1);
3555
progress.set(2);
3656
progress.set(3);
3757
progress.set(4);
3858
progress.set(5);
3959
});
60+
})
61+
.bench_function("inc tree 5 times", |b| {
62+
let root = small_tree();
63+
let progress = root.add_child("the one");
64+
progress.init(Some(20), Some("element".into()));
65+
let progress = BoxedDynNestedProgress::new(progress);
66+
b.iter(|| {
67+
progress.inc();
68+
progress.inc();
69+
progress.inc();
70+
progress.inc();
71+
progress.inc();
72+
});
73+
});
74+
c.benchmark_group("tree::Item")
75+
.throughput(Throughput::Elements(5))
76+
.bench_function("set tree 5 times", |b| {
77+
let root = small_tree();
78+
let progress = root.add_child("the one");
79+
progress.init(Some(20), Some("element".into()));
80+
b.iter(|| {
81+
progress.set(1);
82+
progress.set(2);
83+
progress.set(3);
84+
progress.set(4);
85+
progress.set(5);
86+
});
87+
})
88+
.bench_function("inc tree 5 times", |b| {
89+
let root = small_tree();
90+
let progress = root.add_child("the one");
91+
progress.init(Some(20), Some("element".into()));
92+
b.iter(|| {
93+
progress.inc();
94+
progress.inc();
95+
progress.inc();
96+
progress.inc();
97+
progress.inc();
98+
});
99+
});
100+
c.benchmark_group("Tree::add_child")
101+
.throughput(Throughput::Elements(4))
102+
.bench_function("add children to build a tree of tasks and clear them (in drop)", |b| {
103+
let root = small_tree();
104+
b.iter(|| {
105+
let mut c = root.add_child("1");
106+
let _one = c.add_child("1");
107+
let _two = c.add_child("2");
108+
let _three = c.add_child("3");
109+
});
40110
});
41111
c.benchmark_group("tree::Item::message")
42112
.throughput(Throughput::Elements(1))
43113
.bench_function(
44114
"send one message with a full message buffer (worst case performance)",
45115
|b| {
46116
let root = small_tree();
47-
let mut progress = root.add_child("the one");
117+
let progress = root.add_child("the one");
48118
progress.init(Some(20), Some("element".into()));
49119
b.iter(|| {
50120
progress.message(MessageLevel::Success, "for testing");

examples/units.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ fn main() -> Result {
3131
}
3232

3333
fn work_for_a_long_time_blocking(root: Arc<Tree>) {
34-
let mut bytes = root.add_child_with_id("download unknown", *b"DLUK");
34+
let bytes = root.add_child_with_id("download unknown", *b"DLUK");
3535
bytes.init(
3636
None,
3737
Some(unit::dynamic_and_mode(
3838
unit::Bytes,
3939
unit::display::Mode::with_throughput(),
4040
)),
4141
);
42-
let mut bytes_max = root.add_child_with_id("download", *b"DLKN");
42+
let bytes_max = root.add_child_with_id("download", *b"DLKN");
4343
bytes_max.init(
4444
Some(100_000_000),
4545
Some(unit::dynamic_and_mode(
@@ -48,9 +48,9 @@ fn work_for_a_long_time_blocking(root: Arc<Tree>) {
4848
)),
4949
);
5050

51-
let mut duration = root.add_child_with_id("duration unknown", *b"DRUK");
51+
let duration = root.add_child_with_id("duration unknown", *b"DRUK");
5252
duration.init(None, Some(unit::dynamic(unit::Duration)));
53-
let mut duration_max = root.add_child_with_id("duration", *b"DRKN");
53+
let duration_max = root.add_child_with_id("duration", *b"DRKN");
5454
duration_max.init(
5555
Some(60 * 60 * 24),
5656
Some(unit::dynamic_and_mode(
@@ -64,15 +64,15 @@ fn work_for_a_long_time_blocking(root: Arc<Tree>) {
6464
f.with_decimals(decimals);
6565
f
6666
}
67-
let mut human_count = root.add_child_with_id("item count unknown", *b"ITUK");
67+
let human_count = root.add_child_with_id("item count unknown", *b"ITUK");
6868
human_count.init(
6969
None,
7070
Some(unit::dynamic_and_mode(
7171
unit::Human::new(formatter(0), "items"),
7272
unit::display::Mode::with_throughput(),
7373
)),
7474
);
75-
let mut human_count_max = root.add_child_with_id("item count", *b"ITKN");
75+
let human_count_max = root.add_child_with_id("item count", *b"ITKN");
7676
human_count_max.init(
7777
Some(7_542_241),
7878
Some(unit::dynamic_and_mode(
@@ -81,15 +81,15 @@ fn work_for_a_long_time_blocking(root: Arc<Tree>) {
8181
)),
8282
);
8383

84-
let mut steps = root.add_child_with_id("steps to take unknown", *b"STUK");
84+
let steps = root.add_child_with_id("steps to take unknown", *b"STUK");
8585
steps.init(
8686
None,
8787
Some(unit::dynamic_and_mode(
8888
unit::Range::new("steps"),
8989
unit::display::Mode::with_throughput(),
9090
)),
9191
);
92-
let mut steps_max = root.add_child_with_id("steps to take", *b"STKN");
92+
let steps_max = root.add_child_with_id("steps to take", *b"STKN");
9393
steps_max.init(
9494
Some(100),
9595
Some(unit::dynamic_and_mode(

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ pub mod messages;
6464
pub mod progress;
6565

6666
mod traits;
67-
pub use traits::{Progress, RawProgress, Root, WeakRoot};
67+
pub use traits::{
68+
BoxedDynNestedProgress, Count, DynNestedProgress, DynNestedProgressToNestedProgress, NestedProgress, Progress,
69+
Root, WeakRoot,
70+
};
6871

6972
mod throughput;
7073
pub use crate::throughput::Throughput;

0 commit comments

Comments
 (0)