Skip to content

Commit f88ea94

Browse files
committed
io_uring: remove old stats printing
1 parent e0a719c commit f88ea94

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

src/io_uring.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,10 @@ async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
6161
from: Rc<A>,
6262
to: Rc<B>,
6363
dbg_name: &'static str,
64-
direction: &'static str,
65-
stats_interval: Option<Duration>,
6664
bytes_written: Arc<AtomicUsize>,
6765
) -> Result<(), std::io::Error> {
68-
// For statistics
69-
let mut bytes_out: usize = 0;
70-
let mut bytes_out_last: usize = 0;
71-
let mut report_time = Instant::now();
72-
7366
let mut buf = vec![0u8; BUFFER_LEN];
7467
loop {
75-
// Handle stats printing
76-
if stats_interval.is_some() && report_time.elapsed() > stats_interval.unwrap() {
77-
let transferred_total = ByteSize::b(bytes_out.try_into().unwrap());
78-
let transferred_last = ByteSize::b(bytes_out_last.try_into().unwrap());
79-
80-
let speed: u64 =
81-
(bytes_out_last as f64 / report_time.elapsed().as_secs_f64()).round() as u64;
82-
let speed = ByteSize::b(speed);
83-
84-
info!(
85-
"{} {} transfer: {:#} ({:#}/s), {:#} total",
86-
NAME,
87-
direction,
88-
transferred_last.to_string_as(true),
89-
speed.to_string_as(true),
90-
transferred_total.to_string_as(true),
91-
);
92-
93-
report_time = Instant::now();
94-
bytes_out_last = 0;
95-
}
96-
9768
// things look weird: we pass ownership of the buffer to `read`, and we get
9869
// it back, _even if there was an error_. There's a whole trait for that,
9970
// which `Vec<u8>` implements!
@@ -116,11 +87,7 @@ async fn copy<A: Endpoint<A>, B: Endpoint<B>>(
11687
let n = res?;
11788
debug!("{}: after write, {} bytes", dbg_name, n);
11889
// Increment byte counters for statistics
119-
if stats_interval.is_some() {
120-
bytes_written.fetch_add(n, Ordering::Relaxed);
121-
bytes_out += n;
122-
bytes_out_last += n;
123-
}
90+
bytes_written.fetch_add(n, Ordering::Relaxed);
12491

12592
// Later is now, we want our full buffer back.
12693
// That's why we declared our binding `mut` way back at the start of `copy`,
@@ -247,16 +214,12 @@ pub async fn io_loop(
247214
file.clone(),
248215
stream.clone(),
249216
"USB",
250-
"📲 car to phone",
251-
stats_interval,
252217
stream_bytes.clone(),
253218
));
254219
let mut from_stream = tokio_uring::spawn(copy(
255220
stream.clone(),
256221
file.clone(),
257222
"TCP",
258-
"📱 phone to car",
259-
stats_interval,
260223
file_bytes.clone(),
261224
));
262225

0 commit comments

Comments
 (0)