mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-08 10:56:13 -08:00
test(tunnel): add netns bench warmup (#2623)
This commit is contained in:
1 parent
ed73d318bb
commit
c2f485d42a
1 file changed
+8
-6
@@ -495,14 +495,16 @@ pub(crate) mod tests {
|
||||
let (mut r, _s) = ret.split();
|
||||
let now = Instant::now();
|
||||
let mut count = 0;
|
||||
let warmup = std::time::Duration::from_secs(1);
|
||||
while let Some(Ok(p)) = r.next().await {
|
||||
let elapsed = now.elapsed();
|
||||
if elapsed < warmup {
|
||||
continue;
|
||||
}
|
||||
count += p.payload_len();
|
||||
let elapsed_sec = now.elapsed().as_secs();
|
||||
if elapsed_sec > 0 {
|
||||
bps_clone.store(
|
||||
count as u64 / now.elapsed().as_secs(),
|
||||
std::sync::atomic::Ordering::Relaxed,
|
||||
);
|
||||
let elapsed = (elapsed - warmup).as_secs();
|
||||
if elapsed >= 1 {
|
||||
bps_clone.store(count as u64 / elapsed, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user