Skip to content

Commit

Permalink
Merge pull request #952 from lrh2000/test-benchmark
Browse files Browse the repository at this point in the history
Fix benchmark and update results
  • Loading branch information
whitequark authored Jul 13, 2024
2 parents 0847643 + f7d39d7 commit 7b125ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,14 @@ cargo run --release --example benchmark -- --tap tap0 [reader|writer]
It establishes a connection to itself from a different thread and reads or writes a large amount
of data in one direction.

A typical result (achieved on a Intel Core i7-7500U CPU and a Linux 4.9.65 x86_64 kernel running
on a Dell XPS 13 9360 laptop) is as follows:
A typical result (achieved on a Intel Core i5-13500H CPU and a Linux 6.9.9 x86_64 kernel running
on a LENOVO XiaoXinPro 14 IRH8 laptop) is as follows:

```
$ cargo run -q --release --example benchmark -- --tap tap0 reader
throughput: 2.556 Gbps
throughput: 3.673 Gbps
$ cargo run -q --release --example benchmark -- --tap tap0 writer
throughput: 5.301 Gbps
throughput: 7.905 Gbps
```

## Bare-metal usage examples
Expand Down
38 changes: 16 additions & 22 deletions examples/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::collapsible_if)]

mod utils;

use std::cmp;
Expand Down Expand Up @@ -121,16 +119,14 @@ fn main() {
socket.listen(1234).unwrap();
}

if socket.can_send() {
if processed < AMOUNT {
let length = socket
.send(|buffer| {
let length = cmp::min(buffer.len(), AMOUNT - processed);
(length, length)
})
.unwrap();
processed += length;
}
while socket.can_send() && processed < AMOUNT {
let length = socket
.send(|buffer| {
let length = cmp::min(buffer.len(), AMOUNT - processed);
(length, length)
})
.unwrap();
processed += length;
}

// tcp:1235: sink data
Expand All @@ -139,16 +135,14 @@ fn main() {
socket.listen(1235).unwrap();
}

if socket.can_recv() {
if processed < AMOUNT {
let length = socket
.recv(|buffer| {
let length = cmp::min(buffer.len(), AMOUNT - processed);
(length, length)
})
.unwrap();
processed += length;
}
while socket.can_recv() && processed < AMOUNT {
let length = socket
.recv(|buffer| {
let length = cmp::min(buffer.len(), AMOUNT - processed);
(length, length)
})
.unwrap();
processed += length;
}

match iface.poll_at(timestamp, &sockets) {
Expand Down

0 comments on commit 7b125ef

Please sign in to comment.