mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic: print stats about number of peers per torrent
This commit is contained in:
parent
e3d3e9ab57
commit
51590a3d6c
4 changed files with 38 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ name = "aquatic"
|
|||
[dependencies]
|
||||
bittorrent_udp = { path = "../bittorrent_udp" }
|
||||
dashmap = "3"
|
||||
histogram = "0.6"
|
||||
indexmap = "1"
|
||||
mimalloc = { version = "0.1", default-features = false }
|
||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
use histogram::Histogram;
|
||||
|
||||
pub mod common;
|
||||
pub mod config;
|
||||
pub mod handlers;
|
||||
|
|
@ -55,6 +57,34 @@ pub fn run(){
|
|||
responses_per_second,
|
||||
requests_per_readable_event
|
||||
);
|
||||
|
||||
let mut peers_per_torrent = Histogram::new();
|
||||
|
||||
for torrent in state.torrents.iter(){
|
||||
let num_seeders = torrent.num_seeders.load(Ordering::SeqCst);
|
||||
let num_leechers = torrent.num_leechers.load(Ordering::SeqCst);
|
||||
|
||||
let num_peers = (num_seeders + num_leechers) as u64;
|
||||
|
||||
if let Err(err) = peers_per_torrent.increment(num_peers){
|
||||
eprintln!("error incrementing peers_per_torrent histogram: {}", err)
|
||||
}
|
||||
}
|
||||
|
||||
if peers_per_torrent.entries() != 0 {
|
||||
println!(
|
||||
"peers per torrent: min: {}, p50: {}, p75: {}, p90: {}, p99: {}, p999: {}, max: {}",
|
||||
peers_per_torrent.minimum().unwrap(),
|
||||
peers_per_torrent.percentile(50.0).unwrap(),
|
||||
peers_per_torrent.percentile(75.0).unwrap(),
|
||||
peers_per_torrent.percentile(90.0).unwrap(),
|
||||
peers_per_torrent.percentile(99.0).unwrap(),
|
||||
peers_per_torrent.percentile(99.9).unwrap(),
|
||||
peers_per_torrent.maximum().unwrap(),
|
||||
);
|
||||
|
||||
println!();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue