Skip to content

Commit 47c8109

Browse files
committed
update README
1 parent fe7aa8a commit 47c8109

File tree

2 files changed

+8
-91
lines changed

2 files changed

+8
-91
lines changed

README.md

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,6 @@ they can usually be implemented as one line of rust macro with the help of this
3232
[examples/rust_cookbook.rs](https://github.com/rust-shell-script/rust_cmd_lib/blob/master/examples/rust_cookbook.rs).
3333
Since they are rust code, you can always rewrite them in rust natively in the future, if necessary without spawning external commands.
3434

35-
### What this library looks like
36-
37-
To get a first impression, here is an example from
38-
[examples/dd_test.rs](https://github.com/rust-shell-script/rust_cmd_lib/blob/master/examples/dd_test.rs):
39-
40-
```rust
41-
run_cmd! (
42-
info "Dropping caches at first";
43-
sudo bash -c "echo 3 > /proc/sys/vm/drop_caches";
44-
info "Running with thread_num: $thread_num, block_size: $block_size";
45-
)?;
46-
let cnt = DATA_SIZE / thread_num / block_size;
47-
let now = Instant::now();
48-
(0..thread_num).into_par_iter().for_each(|i| {
49-
let off = cnt * i;
50-
let bandwidth = run_fun!(
51-
sudo bash -c "dd if=$file of=/dev/null bs=$block_size skip=$off count=$cnt 2>&1"
52-
| awk r#"/copied/{print $(NF-1) " " $NF}"#
53-
)
54-
.unwrap_or_else(|_| cmd_die!("thread $i failed"));
55-
info!("thread {i} bandwidth: {bandwidth}");
56-
});
57-
let total_bandwidth = Byte::from_bytes((DATA_SIZE / now.elapsed().as_secs()) as u128).get_appropriate_unit(true);
58-
info!("Total bandwidth: {total_bandwidth}/s");
59-
```
60-
61-
Output will be like this:
62-
63-
```console
64-
rust_cmd_lib git:(master) ✗ cargo run --example dd_test -- -b 4096 -f /dev/nvme0n1 -t 4
65-
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
66-
Running `target/debug/examples/dd_test -b 4096 -f /dev/nvme0n1 -t 4`
67-
[INFO ] Dropping caches at first
68-
[INFO ] Running with thread_num: 4, block_size: 4096
69-
[INFO ] thread 3 bandwidth: 317 MB/s
70-
[INFO ] thread 1 bandwidth: 289 MB/s
71-
[INFO ] thread 0 bandwidth: 281 MB/s
72-
[INFO ] thread 2 bandwidth: 279 MB/s
73-
[INFO ] Total bandwidth: 1.11 GiB/s
74-
```
75-
7635
### What this library provides
7736

7837
#### Macros to run external commands
@@ -294,6 +253,10 @@ let d = tls_get!(DELAY);
294253

295254
### Other Notes
296255

256+
#### Minimum supported Rust version
257+
258+
cmd_lib(2.0)'s MSRV is 1.88.
259+
297260
#### Environment Variables
298261

299262
You can use [std::env::var](https://doc.rust-lang.org/std/env/fn.var.html) to fetch the environment variable

src/lib.rs

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,6 @@
3030
//! [examples/rust_cookbook.rs](https://github.com/rust-shell-script/rust_cmd_lib/blob/master/examples/rust_cookbook.rs).
3131
//! Since they are rust code, you can always rewrite them in rust natively in the future, if necessary without spawning external commands.
3232
//!
33-
//! ## What this library looks like
34-
//!
35-
//! To get a first impression, here is an example from
36-
//! [examples/dd_test.rs](https://github.com/rust-shell-script/rust_cmd_lib/blob/master/examples/dd_test.rs):
37-
//!
38-
//! ```no_run
39-
//! # use byte_unit::Byte;
40-
//! # use cmd_lib::*;
41-
//! # use rayon::prelude::*;
42-
//! # use std::time::Instant;
43-
//! # const DATA_SIZE: u64 = 10 * 1024 * 1024 * 1024; // 10GB data
44-
//! # let mut file = String::new();
45-
//! # let mut block_size: u64 = 4096;
46-
//! # let mut thread_num: u64 = 1;
47-
//! run_cmd! (
48-
//! info "Dropping caches at first";
49-
//! sudo bash -c "echo 3 > /proc/sys/vm/drop_caches";
50-
//! info "Running with thread_num: $thread_num, block_size: $block_size";
51-
//! )?;
52-
//! let cnt = DATA_SIZE / thread_num / block_size;
53-
//! let now = Instant::now();
54-
//! (0..thread_num).into_par_iter().for_each(|i| {
55-
//! let off = cnt * i;
56-
//! let bandwidth = run_fun!(
57-
//! sudo bash -c "dd if=$file of=/dev/null bs=$block_size skip=$off count=$cnt 2>&1"
58-
//! | awk r#"/copied/{print $(NF-1) " " $NF}"#
59-
//! )
60-
//! .unwrap_or_else(|_| cmd_die!("thread $i failed"));
61-
//! info!("thread {i} bandwidth: {bandwidth}");
62-
//! });
63-
//! let total_bandwidth = Byte::from_bytes((DATA_SIZE / now.elapsed().as_secs()) as u128).get_appropriate_unit(true);
64-
//! info!("Total bandwidth: {total_bandwidth}/s");
65-
//! # Ok::<(), std::io::Error>(())
66-
//! ```
67-
//!
68-
//! Output will be like this:
69-
//!
70-
//! ```console
71-
//! ➜ rust_cmd_lib git:(master) ✗ cargo run --example dd_test -- -b 4096 -f /dev/nvme0n1 -t 4
72-
//! Finished dev [unoptimized + debuginfo] target(s) in 0.04s
73-
//! Running `target/debug/examples/dd_test -b 4096 -f /dev/nvme0n1 -t 4`
74-
//! [INFO ] Dropping caches at first
75-
//! [INFO ] Running with thread_num: 4, block_size: 4096
76-
//! [INFO ] thread 3 bandwidth: 317 MB/s
77-
//! [INFO ] thread 1 bandwidth: 289 MB/s
78-
//! [INFO ] thread 0 bandwidth: 281 MB/s
79-
//! [INFO ] thread 2 bandwidth: 279 MB/s
80-
//! [INFO ] Total bandwidth: 1.11 GiB/s
81-
//! ```
82-
//!
8333
//! ## What this library provides
8434
//!
8535
//! ### Macros to run external commands
@@ -324,6 +274,10 @@
324274
//!
325275
//! ## Other Notes
326276
//!
277+
//! ### Minimum supported Rust version
278+
//!
279+
//! cmd_lib(2.0)'s MSRV is 1.88.
280+
//!
327281
//! ### Environment Variables
328282
//!
329283
//! You can use [std::env::var](https://doc.rust-lang.org/std/env/fn.var.html) to fetch the environment variable

0 commit comments

Comments
 (0)