ws load test: provide stats on number of active connections

This commit is contained in:
Joakim Frostegård 2023-01-25 22:49:24 +01:00
parent 1d8eec3c44
commit 3d2ae26b13
3 changed files with 8 additions and 0 deletions

View file

@ -92,6 +92,8 @@ impl Connection {
);
let (stream, _) = client_async(request, stream).await?;
let statistics = load_test_state.statistics.clone();
let mut connection = Connection {
config,
load_test_state,
@ -103,12 +105,14 @@ impl Connection {
};
*num_active_connections.borrow_mut() += 1;
statistics.connections.fetch_add(1, Ordering::Relaxed);
if let Err(err) = connection.run_connection_loop().await {
::log::info!("connection error: {:#}", err);
}
*num_active_connections.borrow_mut() -= 1;
statistics.connections.fetch_sub(1, Ordering::Relaxed);
Ok(())
}