Skip to content

Commit bb14856

Browse files
committed
Refactoring: Seperate utils-box-stopwatch
1 parent 1e5d029 commit bb14856

7 files changed

Lines changed: 404 additions & 31 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ members = [
1010
"utils-box-logger",
1111
"utils-box-mathematics",
1212
"utils-box-pathfinder",
13-
# "utils-box-stopwatch",
13+
"utils-box-stopwatch",
14+
# "utils-box-threads",
15+
# "utils-box-versions",
1416
]

utils-box-pathfinder/Cargo.toml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,19 @@ repository = "https://github.com/klispap/utils-box"
1717
utils-box-logger = "1.0.1"
1818
anyhow = "1.0.100"
1919
log = "0.4.28"
20-
simplelog = "0.11.2"
21-
file-rotate = "0.7.6"
22-
chrono = "0.4.42"
23-
lazy_static = "1.5.0"
24-
tokio = { version = "1", features = [
25-
"rt",
26-
"net",
27-
"macros",
28-
"time",
29-
"rt-multi-thread",
30-
] }
31-
tokio-util = "0.6.10"
3220
futures = "0.3.31"
3321
rayon = "1.11.0"
3422
walkdir = "2.5.0"
35-
tar = "0.4.44"
36-
zmq = "0.10.0"
23+
chrono = "0.4.42"
24+
names = "0.14.0"
3725
glob = "0.3.3"
38-
flate2 = "1.1"
39-
semver = "1.0.27"
40-
zip = { version = "0.6.6", default-features = false, features = ["deflate"] }
4126
regex = "1.11.2"
42-
names = "0.14.0"
43-
rust-ini = "0.18.0"
4427
directories = "5.0.1"
4528

46-
[target.'cfg(unix)'.dependencies]
47-
ssh2 = { version = "0.9.5", features = ["vendored-openssl"] }
48-
signal-hook = "0.3.18"
49-
signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"] }
50-
5129
[dev-dependencies]
5230
indoc = "1.0.9"
5331
tempfile = "3.22.0"
5432
named-lock = "0.3.0"
5533

5634
[lints.rust]
5735
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
58-
59-
[features]
60-
default = ["archives", "math"]
61-
archives = []
62-
math = []
63-
connections = []

utils-box-stopwatch/Cargo.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[package]
2+
name = "utils-box-stopwatch"
3+
version = "1.0.1"
4+
edition = "2024"
5+
authors = ["Agathoklis Papadopoulos <klis.pap@gmail.com>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
publish = ["crates-io"]
9+
10+
description = "A toolbox of various small RUST utilities that make measuring code execution easier"
11+
categories = ["development-tools", "config", "network-programming", "parsing"]
12+
keywords = ["tools", "utilities", "utils", "toolbox"]
13+
exclude = [".github", "Cargo.toml.orig", "cargo_vcs_info.json"]
14+
repository = "https://github.com/klispap/utils-box"
15+
16+
[dependencies]
17+
utils-box-logger = "1.0.1"
18+
anyhow = "1.0.100"
19+
log = "0.4.28"
20+
simplelog = "0.11.2"
21+
file-rotate = "0.7.6"
22+
chrono = "0.4.42"
23+
lazy_static = "1.5.0"
24+
tokio = { version = "1", features = [
25+
"rt",
26+
"net",
27+
"macros",
28+
"time",
29+
"rt-multi-thread",
30+
] }
31+
tokio-util = "0.6.10"
32+
futures = "0.3.31"
33+
rayon = "1.11.0"
34+
walkdir = "2.5.0"
35+
tar = "0.4.44"
36+
zmq = "0.10.0"
37+
glob = "0.3.3"
38+
flate2 = "1.1"
39+
semver = "1.0.27"
40+
zip = { version = "0.6.6", default-features = false, features = ["deflate"] }
41+
regex = "1.11.2"
42+
names = "0.14.0"
43+
rust-ini = "0.18.0"
44+
directories = "5.0.1"
45+
46+
[target.'cfg(unix)'.dependencies]
47+
ssh2 = { version = "0.9.5", features = ["vendored-openssl"] }
48+
signal-hook = "0.3.18"
49+
signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"] }
50+
51+
[dev-dependencies]
52+
indoc = "1.0.9"
53+
tempfile = "3.22.0"
54+
named-lock = "0.3.0"
55+
56+
[lints.rust]
57+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
58+
59+
[features]
60+
default = ["archives", "math"]
61+
archives = []
62+
math = []
63+
connections = []

utils-box-stopwatch/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Agathoklis Papadopoulos
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

utils-box-stopwatch/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[![Coverage Status](https://coveralls.io/repos/github/klispap/utils-box/badge.svg?branch=main)](https://coveralls.io/github/klispap/utils-box?branch=main)
2+
3+
# Summary
4+
A toolbox library that holds a useful collection of small unitilies written in Rust that make our life easier when writting Rust applications.
5+
6+
# Utilities provided:
7+
8+
## Stopwatch and Timekeper
9+
Keep track of execution times in various points in binaries. Print records.
10+
11+
Minimal Example:
12+
```rust
13+
let mut s = TimeKeeper::init();
14+
let mut t = TimeKeeper::init();
15+
16+
s.totals();
17+
18+
s.lap("init");
19+
20+
for _ in 0..5 {
21+
std::thread::sleep(Duration::from_millis(5));
22+
s.lap("loop");
23+
t.lap("loop");
24+
}
25+
s.lap_totals("loop");
26+
std::thread::sleep(Duration::from_millis(1234));
27+
s.lap("after");
28+
29+
s.totals();
30+
t.totals();
31+
32+
s.merge(t);
33+
34+
s.totals();
35+
36+
```
37+
38+
# Tips for resolving Ubuntu 22.04/24.04 build issues:
39+
40+
1) Make sure you have the following system-level dependencies installed:
41+
```
42+
sudo apt install pkg-config build-essential fontconfig libfontconfig1-dev
43+
```
44+
45+
2) Verify that `pkg-config` can detect `libstdc++` properly:
46+
```
47+
pkg-config --libs libstdc++
48+
```
49+
50+
3) If `libstdc++` is not detected, add the symbolic link:
51+
```
52+
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.so /usr/lib/libstdc++.so
53+
```
54+

utils-box-stopwatch/src/lib.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//! # Summary
2+
//! A toolbox library that holds a useful collection of small unitilies written in Rust that make our life easier when writting Rust applications.
3+
//!
4+
//! # Utilities provided:
5+
//!
6+
//! ## Mathematics
7+
//! A collection of useful methematic methods used in various DSP and other applications
8+
//!
9+
//! ## Stopwatch and Timekeper
10+
//! Keep track of execution times in various points in binaries. Print records.
11+
//!
12+
//! Minimal Example:
13+
//! ```ignore
14+
//! let mut s = TimeKeeper::init();
15+
//! let mut t = TimeKeeper::init();
16+
//!
17+
//! s.totals();
18+
//!
19+
//! s.lap("init");
20+
//!
21+
//! for _ in 0..5 {
22+
//! std::thread::sleep(Duration::from_millis(5));
23+
//! s.lap("loop");
24+
//! t.lap("loop");
25+
//! }
26+
//! s.lap_totals("loop");
27+
//! std::thread::sleep(Duration::from_millis(1234));
28+
//! s.lap("after");
29+
//!
30+
//! s.totals();
31+
//! t.totals();
32+
//!
33+
//! s.merge(t);
34+
//!
35+
//! s.totals();
36+
//!
37+
//! ```
38+
//!
39+
40+
pub mod stopwatch;

0 commit comments

Comments
 (0)