Skip to content

Commit 83bb5e4

Browse files
committed
add Performance to README.md
1 parent 923ff1d commit 83bb5e4

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,38 @@ Main APIs include:
6767
- `Queue::is_full()` - Check if queue is full
6868
- `Queue::is_closed()` - Check if queue is closed
6969

70+
## Performance
71+
72+
The following performance tests were conducted on a lightweight server with 2 CPU cores and 4GB RAM:
73+
74+
- **tokio-mpmc**:
75+
- Queue size: 1,000,000
76+
- Producers: 4
77+
- Consumers: 4
78+
- Performance test finished in: 318.360935ms
79+
80+
- **tokio::sync::mpsc**:
81+
- Queue size: 1,000,000
82+
- Producers: 4
83+
- Consumers: 1
84+
- Performance test finished in: 987.390354ms
85+
86+
- **tokio-mpmc IO**:
87+
- Queue size: 1,000,000
88+
- Producers: 4
89+
- Consumers: 4
90+
- IO performance test finished in: 4.495057117s
91+
92+
- **tokio::sync::mpsc IO**:
93+
- Queue size: 1,000,000
94+
- Producers: 4
95+
- Consumers: 1
96+
- IO performance test finished in: 7.671314196s
97+
98+
These results demonstrate the efficiency of tokio-mpmc in handling multiple producers and consumers compared to tokio::sync::mpsc.
99+
100+
> See [benchmark code](./examples/performance-test.rs)
101+
70102
## License
71103

72104
This project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.

examples/performance-test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ async fn main() {
1111
let num_producers = 4;
1212
let num_consumers = 4;
1313

14+
println!("============================================");
15+
println!("Starting non-IO tests");
1416
run_tokio_mpmc_test(
1517
queue_size as u32,
1618
num_producers as u32,
@@ -19,7 +21,8 @@ async fn main() {
1921
.await;
2022
run_tokio_mpsc_test(queue_size as u32, num_producers as u32).await;
2123

22-
let queue_size = 100_000;
24+
println!("============================================");
25+
println!("Starting IO tests");
2326
run_tokio_mpmc_io_test(
2427
queue_size as u32,
2528
num_producers as u32,

examples/tests/tokio_mpsc_io_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use tokio::sync::mpsc;
77
pub async fn run_tokio_mpsc_io_test(queue_size: u32, num_producers: u32) -> std::time::Duration {
88
let num_consumers = 1;
99
println!(
10-
"Starting tokio::sync::mpsc performance test with queue size: {}, producers: {}, consumers: {}",
10+
"Starting tokio::sync::mpsc io performance test with queue size: {}, producers: {}, consumers: {}",
1111
queue_size, num_producers, num_consumers
1212
);
1313

0 commit comments

Comments
 (0)