浏览代码

Fix benchmark and update results

Ruihan Li 8 月之前
父节点
当前提交
f7d39d72a1
共有 2 个文件被更改,包括 20 次插入26 次删除
  1. 4 4
      README.md
  2. 16 22
      examples/benchmark.rs

+ 4 - 4
README.md

@@ -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

+ 16 - 22
examples/benchmark.rs

@@ -1,5 +1,3 @@
-#![allow(clippy::collapsible_if)]
-
 mod utils;
 
 use std::cmp;
@@ -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
@@ -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) {