Skip to content

updating the throughput calculation in data_channel_flow_control #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,28 @@ async fn create_responder() -> anyhow::Result<RTCPeerConnection> {
Box::pin(async {
// This callback shouldn't be blocked for a long time, so we spawn our handler
tokio::spawn(async move {
let start = SystemTime::now();
let mut start = SystemTime::now();
let mut last_total_bytes_received: usize = 0;

tokio::time::sleep(Duration::from_secs(1)).await;
println!();

loop {
let total_bytes_received =
shared_total_bytes_received.load(Ordering::Relaxed);
let epoch_bytes_received =
total_bytes_received - last_total_bytes_received;
last_total_bytes_received = total_bytes_received;

let elapsed = SystemTime::now().duration_since(start);
let bps =
(total_bytes_received * 8) as f64 / elapsed.unwrap().as_secs_f64();
(epoch_bytes_received * 8) as f64 / elapsed.unwrap().as_secs_f64();

println!(
"Throughput is about {:.03} Mbps",
bps / (1024 * 1024) as f64
);
start = SystemTime::now();
tokio::time::sleep(Duration::from_secs(1)).await;
}
});
Expand Down
Loading