#delays #events #recording #analyzing #tokio #loops #eld

tokio-eld

Histogram-based sampler for recording and analyzing event loop delays

2 unstable releases

0.2.0 Nov 17, 2024
0.1.0 Nov 16, 2024

#567 in Math

Download history 849/week @ 2024-11-16 951/week @ 2024-11-23 1210/week @ 2024-11-30 1711/week @ 2024-12-07 1595/week @ 2024-12-14 1541/week @ 2024-12-21 1450/week @ 2024-12-28 1326/week @ 2025-01-04 2067/week @ 2025-01-11 1564/week @ 2025-01-18 1903/week @ 2025-01-25 1520/week @ 2025-02-01 1643/week @ 2025-02-08

7,119 downloads per month
Used in 13 crates (via deno_node)

MIT/Apache

7KB
82 lines

Crates.io

Documentation

tokio_eld provides a histogram-based sampler for recording and analyzing event loop delays in a current_thread Tokio runtime. The API is similar to Node.js's perf_hooks.monitorEventLoopDelay().

use tokio_eld::EldHistogram;

let mut histogram = EldHistogram::<u64>::new(20)?; // 20 ms resolution

h.start();
// do some work
h.stop();

println!("min: {}", h.min());
println!("max: {}", h.max());
println!("mean: {}", h.mean());
println!("stddev: {}", h.stdev());
println!("p50: {}", h.value_at_percentile(50.0));
println!("p90: {}", h.value_at_percentile(90.0));

lib.rs:

tokio_eld provides a histogram-based sampler for recording and analyzing event loop delays in a current_thread Tokio runtime. The API is similar to Node.js's perf_hooks.monitorEventLoopDelay().

EldHistogram

EldHistogram supports recording and analyzing event loop delay using a High Dynamic Range (HDR) Histogram. The recorded delays are in nanoseconds.

Refer to documentation for hdrhistogram::Histogram for more information on how to use the core data structure.

Usage

use tokio_eld::EldHistogram;

let mut h = EldHistogram::<u64>::new(20).unwrap();
h.start();
// do some work
h.stop();

println!("min: {}", h.min());
println!("max: {}", h.max());
println!("mean: {}", h.mean());
println!("stddev: {}", h.stdev());
println!("p50: {}", h.value_at_percentile(50.0));
println!("p90: {}", h.value_at_percentile(90.0));

Dependencies

~2.5–8.5MB
~56K SLoC