id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | #[test]
fn log_histogram_default_configuration() {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_time_histogram()
.metrics_poll_time_histogram_configuration(HistogramConfiguration::log(
LogHistogram::default(),
))
.build... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | for rt in rts {
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {}).await.unwrap();
}
});
drop(rt);
let num_workers = metrics.num_workers();
let num_buckets = metrics.poll_time_histogram_num_bucke... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | // ensure the old methods work too
#[allow(deprecated)]
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_time_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Log)
.metrics_poll_count_histogram_buckets(3)
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | ];
for rt in rts {
let metrics = rt.metrics();
assert!(!metrics.poll_time_histogram_enabled());
}
}
#[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | .unwrap();
}
});
drop(rt);
for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).aw... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | assert_eq!(1, metrics.remote_schedule_count());
}
#[test]
fn worker_overflow_count() {
// Only applies to the threaded worker
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::ch... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | let n: u64 = (0..metrics.num_workers())
.map(|i| metrics.worker_overflow_count(i))
.sum();
assert_eq!(1, n);
}
#[test]
fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | rx1.recv().unwrap();
// Spawn some tasks
for _ in 0..100 {
tokio::spawn(async {});
}
let n: usize = (0..metrics.num_workers())
.map(|i| metrics.worker_local_queue_depth(i))
.sum();
assert_eq!(n, N);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | return Poll::Pending;
}
}));
assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[test]
fn budget_exhaustion_yield_with_joins() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield_1 = false;
let mu... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:21 | if fut.poll(cx).is_pending() {
did_yield_2 = true;
return Poll::Pending;
}
})
)
});
assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:22 | assert_eq!(metrics.io_driver_ready_count(), 1);
}
async fn try_spawn_stealable_task() -> Result<(), mpsc::RecvTimeoutError> {
// We use a blocking channel to synchronize the tasks.
let (tx, rx) = mpsc::channel();
// Make sure we are in the context of the runtime.
tokio::spawn(async move {
// S... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 841 | 895 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:23 | .unwrap()
}
fn threaded_no_lifo() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.disable_lifo_slot()
.enable_all()
.build()
.unwrap()
}
fn us(n: u64) -> Duration {
Duration::from_micros(n)
} | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4a34b77af5b6ae8addb8f60cfbda5dd2686b61d3/tokio/tests/rt_unstable_metrics.rs | 881 | 895 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{mpsc, Arc, Mutex};
use std::task::Poll;
use std::thread;
use tokio::macros::support::poll_fn;... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | assert_eq!(num_buckets, 119);
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {}).await.unwrap();
}
});
drop(rt);
assert_eq!(
metrics.poll_time_histogram_bucket_range(0),
Duration::from_nanos(0)..Duration::from_nanos(96)
);
assert_eq!(
m... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | #[test]
fn worker_poll_count_histogram() {
const N: u64 = 5;
let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_time_histogram()
.metrics_poll_time_histogram_configuration(HistogramConfiguration::linear(
Durat... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(move |j| (i, j)))
.map(|(worker, bucket)| metrics.poll_time_histogram_bucket_count(worker, bucket))
.sum();
assert_eq!(N, n);
}
}
#[test]
fn worker_poll_count_histogram_range() {
let max = Duration::from_nan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | assert_eq!(metrics.poll_time_histogram_bucket_range(0), us(0)..a);
assert_eq!(metrics.poll_time_histogram_bucket_range(1), a..b);
assert_eq!(metrics.poll_time_histogram_bucket_range(2), b..max);
}
#[test]
fn worker_poll_count_histogram_disabled_without_explicit_enable() {
let rts = [
tokio::runtime... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
})
.await
.unwrap();
}
});
drop(rt);
assert!(zero < metrics.worker_total_busy_duration(0));
let rt ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt);
assert_eq!(1, metrics.worker_local_schedule_count(0));
assert_eq!(0, metrics.remote_schedule_count());
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | // been spawned.
//
// We spawn from outside the runtime to ensure that the other worker
// will pick it up:
// <https://github.com/tokio-rs/tokio/issues/4730>
tokio::task::spawn_blocking(|| {
tokio::spawn(async move {
tx1.s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async move {
// Move to the runtime
tokio::spawn(async move {
let (tx1, rx1) = std::syn... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | .await
.unwrap();
});
}
#[test]
fn budget_exhaustion_yield() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield = false;
// block on a task which consumes budget until it yields
rt.block_on(poll_fn(|cx| l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | let mut did_yield_2 = false;
// block on a task which consumes budget until it yields
rt.block_on(async {
tokio::join!(
poll_fn(|cx| loop {
if did_yield_1 {
return Poll::Ready(());
}
let fut = consume_budget();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:21 | let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(metrics.io_driver_fd_registered_count(), 0);
let stream = tokio::net::TcpStream::connect("google.com:80");
let stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_driver_fd_registered_count(), 1);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:22 | tx.send(()).unwrap();
});
// Blocking receive on the channel, timing out if the sending task
// wasn't scheduled in time.
rx.recv_timeout(Duration::from_secs(1))
})
.await
.unwrap()?;
Ok(())
}
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_th... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 4468f27c319bf54ed973128e7257a337fb0c5374 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4468f27c319bf54ed973128e7257a337fb0c5374/tokio/tests/rt_unstable_metrics.rs | 841 | 880 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{Arc, Mutex};
use std::task::Poll;
use std::thread;
use tokio::macros::support::poll_fn;
use ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:7 | drop(rt);
assert!(2 <= metrics.worker_park_unpark_count(0));
let rt = threaded();
let metrics = rt.metrics();
// Wait for workers to be parked after runtime startup.
for _ in 0..100 {
if 1 <= metrics.worker_park_unpark_count(0) && 1 <= metrics.worker_park_unpark_count(1) {
brea... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:8 | rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(0 < metrics.worker_noop_count(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(0 < metri... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:9 | rx.recv().unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
.map(|i| metrics.worker_steal_count(i))
.sum();
assert_eq!(1, n);
}
#[test]
fn worker_poll_count_and_time() {
const N: u64 = 5;
async fn task() {
//... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:10 | }
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
// Account for the `block_on` task
let n = (0..metrics.num_workers())
.map(|i| metrics.worker_poll_count(i))
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | .max_value(Duration::from_secs(60))
.min_value(Duration::from_nanos(100))
.max_error(0.25),
))
.build()
.unwrap();
let metrics = rt.metrics();
let num_buckets = rt.metrics().poll_time_histogram_num_buckets();
assert_eq!(num_buckets, 119);
rt.block_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | LogHistogram::default(),
))
.build()
.unwrap();
let num_buckets = rt.metrics().poll_time_histogram_num_buckets();
assert_eq!(num_buckets, 119);
}
#[test]
fn worker_poll_count_histogram() {
const N: u64 = 5;
let rts = [
tokio::runtime::Builder::new_current_thread()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | });
drop(rt);
let num_workers = metrics.num_workers();
let num_buckets = metrics.poll_time_histogram_num_buckets();
assert!(metrics.poll_time_histogram_enabled());
assert_eq!(num_buckets, 3);
let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(move ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | .metrics_poll_count_histogram_resolution(us(50))
.build()
.unwrap();
let metrics = rt.metrics();
let a = Duration::from_nanos(50000_u64.next_power_of_two());
let b = a * 2;
assert_eq!(metrics.poll_time_histogram_bucket_range(0), us(0)..a);
assert_eq!(metrics.poll_time_histogram_buc... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | #[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
})
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt);
assert_eq!(1, metrics.worker_local_schedule_count(0)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we need to block the other worker until all tasks have
// b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | #[test]
fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | let n: usize = (0..metrics.num_workers())
.map(|i| metrics.worker_local_queue_depth(i))
.sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[test]
fn budget_exhaustion_yield() {
let rt = current_thread();... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | #[test]
fn budget_exhaustion_yield_with_joins() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield_1 = false;
let mut did_yield_2 = false;
// block on a task which consumes budget until it yields
rt.block_on(async... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:21 | });
assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(metrics.io_driver_fd_registered_count(), 0);
let stream = tokio::net::TcpStream... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:22 | .build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
}
fn threaded_no_lifo() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.disable_l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | fbfeb9a68a22556935b64dc426601b799ec369ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/fbfeb9a68a22556935b64dc426601b799ec369ac/tokio/tests/rt_unstable_metrics.rs | 841 | 864 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:9 | rx.recv().unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
.map(|i| metrics.worker_steal_count(i))
.sum();
assert_eq!(1, n);
}
#[test]
fn worker_poll_count_and_time() {
const N: u64 = 5;
async fn task() {
//... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:10 | }
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
// Account for the `block_on` task
let n = (0..metrics.num_workers())
.map(|i| metrics.worker_poll_count(i))
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | .max_value(Duration::from_secs(60))
.min_value(Duration::from_nanos(100))
.max_error(0.25),
))
.build()
.unwrap();
let metrics = rt.metrics();
let num_buckets = rt.metrics().poll_count_histogram_num_buckets();
assert_eq!(num_buckets, 119);
rt.block... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | LogHistogram::default(),
))
.build()
.unwrap();
let num_buckets = rt.metrics().poll_count_histogram_num_buckets();
assert_eq!(num_buckets, 119);
}
#[test]
fn worker_poll_count_histogram() {
const N: u64 = 5;
let rts = [
tokio::runtime::Builder::new_current_thread()
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | });
drop(rt);
let num_workers = metrics.num_workers();
let num_buckets = metrics.poll_count_histogram_num_buckets();
assert!(metrics.poll_count_histogram_enabled());
assert_eq!(num_buckets, 3);
let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(mov... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | .enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Log)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(us(50))
.build()
.unwrap();
let metrics = rt.metrics();
let a = Duration::fro... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | assert!(!metrics.poll_count_histogram_enabled());
}
}
#[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | drop(rt);
for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | fn worker_overflow_count() {
// Only applies to the threaded worker
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::chan... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | assert_eq!(1, n);
}
#[test]
fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_queue_depth(0));
});
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | tokio::spawn(async {});
}
let n: usize = (0..metrics.num_workers())
.map(|i| metrics.worker_local_queue_depth(i))
.sum();
assert_eq!(n, N);
tx2.send(()).unwrap();
})
.await
.unwrap();
});
}
#[test]
fn budget_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[test]
fn budget_exhaustion_yield_with_joins() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield_1 = false;
let mut did_yield_2 = false;
// block on a task... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:21 | }
})
)
});
assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(metrics.io_driver_fd_registered_count(), 0);
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 801 | 860 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:22 | fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
}
fn threaded_no_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | da745ff335dea94378f5ba2b79e2c9f97cb217aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/da745ff335dea94378f5ba2b79e2c9f97cb217aa/tokio/tests/rt_unstable_metrics.rs | 841 | 867 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{Arc, Mutex};
use std::task::Poll;
use std::thread;
use tokio::macros::support::poll_fn;
use ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:10 | }
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
// Account for the `block_on` task
let n = (0..metrics.num_workers())
.map(|i| metrics.worker_poll_count(i))
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | .metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(Duration::from_millis(50))
.build()
.unwrap(),
tokio::runtime::Builder::new_multi_thread()
.wo... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | fn worker_poll_count_histogram_range() {
let max = Duration::from_nanos(u64::MAX);
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_pol... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | let rts = [
tokio::runtime::Builder::new_current_thread()
.enable_all()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Linear)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(Duration::from_millis(50))
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | }
});
drop(rt);
assert!(zero < metrics.worker_total_busy_duration(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
})
.await
.... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
tokio::spawn(async {}).await.unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
.map(|i| metrics.worker_local_schedul... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | });
});
rx1.recv().unwrap();
// Spawn many tasks
for _ in 0..300 {
tokio::spawn(async {});
}
tx2.send(()).unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | rt.block_on(async move {
// Move to the runtime
tokio::spawn(async move {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we need to block the other worker until all tasks have
// been spawned.
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield = false;
// block on a task which consumes budget until it yields
rt.block_on(poll_fn(|cx| loop {
if did_yield {
return Poll::Ready(());
}
let fut = consume_budget();
tokio::pin!(fut);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | let fut = consume_budget();
tokio::pin!(fut);
if fut.poll(cx).is_pending() {
did_yield_1 = true;
return Poll::Pending;
}
}),
poll_fn(|cx| loop {
if did_yield_2 {
return Po... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | assert_eq!(metrics.io_driver_fd_deregistered_count(), 0);
drop(stream);
assert_eq!(metrics.io_driver_fd_deregistered_count(), 1);
assert_eq!(metrics.io_driver_fd_registered_count(), 1);
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_ready_count() {
let rt = current_threa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 542197cdb9031384b05ab81b64c6b6dc057a3dfc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/542197cdb9031384b05ab81b64c6b6dc057a3dfc/tokio/tests/rt_unstable_metrics.rs | 761 | 807 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{Arc, Barrier, Mutex};
use std::task::Poll;
use std::thread;
use tokio::macros::support::poll_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | });
});
rx1.recv().unwrap();
// Spawn many tasks
for _ in 0..300 {
tokio::spawn(async {});
}
tx2.send(()).unwrap();
})
.await
.unwrap();
});
drop(rt);
let n: u64 = (0..metrics.num_workers())
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:17 | #[test]
fn injection_queue_depth_multi_thread() {
let rt = threaded();
let metrics = rt.metrics();
let barrier1 = Arc::new(Barrier::new(3));
let barrier2 = Arc::new(Barrier::new(3));
// Spawn a task per runtime worker to block it.
for _ in 0..2 {
let barrier1 = barrier1.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 641 | 700 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:18 | assert_eq!(N, metrics.worker_local_queue_depth(0));
});
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async move {
// Move to the runtime
tokio::spawn(async move {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::chann... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 681 | 740 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | #[test]
fn budget_exhaustion_yield() {
let rt = current_thread();
let metrics = rt.metrics();
assert_eq!(0, metrics.budget_forced_yield_count());
let mut did_yield = false;
// block on a task which consumes budget until it yields
rt.block_on(poll_fn(|cx| loop {
if did_yield {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | tokio::join!(
poll_fn(|cx| loop {
if did_yield_1 {
return Poll::Ready(());
}
let fut = consume_budget();
tokio::pin!(fut);
if fut.poll(cx).is_pending() {
did_yield_1 = true;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 761 | 820 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:21 | let stream = tokio::net::TcpStream::connect("google.com:80");
let stream = rt.block_on(async move { stream.await.unwrap() });
assert_eq!(metrics.io_driver_fd_registered_count(), 1);
assert_eq!(metrics.io_driver_fd_deregistered_count(), 0);
drop(stream);
assert_eq!(metrics.io_driver_fd_deregistere... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 90b23a9584db99ae81fffee38a89a09d2eca1834 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90b23a9584db99ae81fffee38a89a09d2eca1834/tokio/tests/rt_unstable_metrics.rs | 801 | 852 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:1 | #![allow(unknown_lints, unexpected_cfgs)]
#![warn(rust_2018_idioms)]
#![cfg(all(
feature = "full",
tokio_unstable,
not(target_os = "wasi"),
target_has_atomic = "64"
))]
use std::future::Future;
use std::sync::{Arc, Barrier, Mutex};
use std::task::Poll;
use tokio::macros::support::poll_fn;
use tokio::r... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 1 | 60 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:4 | fn remote_schedule_count() {
use std::thread;
let rt = current_thread();
let handle = rt.handle().clone();
let task = thread::spawn(move || {
handle.spawn(async {
// DO nothing
})
})
.join()
.unwrap();
rt.block_on(task).unwrap();
assert_eq!(1, rt.metric... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:5 | assert!(1 <= metrics.worker_park_count(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(1 <= metrics.worker_park_count(0));
assert!(1 <= metrics.worker_park_count(1));
}
#[test]
fn worker_pa... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:6 | }
assert!(3 <= metrics.worker_park_unpark_count(0) || 3 <= metrics.worker_park_unpark_count(1));
// Both threads unpark for runtime shutdown.
drop(rt);
assert_eq!(0, metrics.worker_park_unpark_count(0) % 2);
assert_eq!(0, metrics.worker_park_unpark_count(1) % 2);
assert!(4 <= metrics.worker_par... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:7 | let rt = threaded_no_lifo();
let metrics = rt.metrics();
rt.block_on(async {
let (tx, rx) = channel();
// Move to the runtime.
tokio::spawn(async move {
// Spawn the task that sends to the channel
//
// Since the lifo slot is disabled, this task is s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:8 | let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
assert_eq!(N, metrics.worker_poll_count(0));
// Not currently supported for current-thread runtime
assert_eq!(Duration::... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:9 | // Does not populate the histogram
assert!(!metrics.poll_count_histogram_enabled());
for n in 0..metrics.num_workers() {
for i in 0..10 {
assert_eq!(0, metrics.poll_count_histogram_bucket_count(n, i));
}
}
}
#[test]
fn worker_poll_count_histogram() {
const N: u64 = 5;
l... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:10 | drop(rt);
let num_workers = metrics.num_workers();
let num_buckets = metrics.poll_count_histogram_num_buckets();
assert!(metrics.poll_count_histogram_enabled());
assert_eq!(num_buckets, 3);
let n = (0..num_workers)
.flat_map(|i| (0..num_buckets).map(move |j| (i, j)... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | .metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Log)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(us(50))
.build()
.unwrap();
let metrics = rt.metrics();
let a = Duration::from_nanos(50000_u64.next_power_of_two());
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we need to block the other worker until all tasks have
// b... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:15 | #[test]
fn injection_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = rt.handle().clone();
let metrics = rt.metrics();
thread::spawn(move || {
handle.spawn(async {});
})
.join()
.unwrap();
assert_eq!(1, metrics.injection_queue_depth()... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 561 | 620 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:16 | rt.spawn(async {});
}
barrier2.wait();
}
#[test]
fn worker_local_queue_depth() {
const N: usize = 100;
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {});
}
assert_eq!(N, metrics.worker_local_q... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 601 | 660 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:19 | did_yield_2 = true;
return Poll::Pending;
}
})
)
});
assert_eq!(1, rt.metrics().budget_forced_yield_count());
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn io_driver_fd_count() {
let rt = current_thread();
let metrics = rt.me... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 721 | 780 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:20 | }
fn current_thread() -> Runtime {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
}
fn threaded() -> Runtime {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()
.unwrap()
}
fn threaded_... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | b69f16aa219818bc75e7ae6a22631d4e574efd39 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b69f16aa219818bc75e7ae6a22631d4e574efd39/tokio/tests/rt_unstable_metrics.rs | 761 | 789 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:4 | fn remote_schedule_count() {
use std::thread;
let rt = current_thread();
let handle = rt.handle().clone();
let task = thread::spawn(move || {
handle.spawn(async {
// DO nothing
})
})
.join()
.unwrap();
rt.block_on(task).unwrap();
assert_eq!(1, rt.metric... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 121 | 180 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:5 | assert!(1 <= metrics.worker_park_count(0));
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
time::sleep(Duration::from_millis(1)).await;
});
drop(rt);
assert!(1 <= metrics.worker_park_count(0));
assert!(1 <= metrics.worker_park_count(1));
}
#[test]
fn worker_no... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 161 | 220 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:6 | // We use a blocking channel to backup one worker thread.
use std::sync::mpsc::channel;
let rt = threaded_no_lifo();
let metrics = rt.metrics();
rt.block_on(async {
let (tx, rx) = channel();
// Move to the runtime.
tokio::spawn(async move {
// Spawn the task that s... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 201 | 260 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:7 | std::thread::sleep(std::time::Duration::from_micros(10));
}
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(task()).await.unwrap();
}
});
drop(rt);
assert_eq!(N, metrics.worker_poll_count(0));
// Not cur... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 241 | 300 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:8 | assert!(n > Duration::default());
// Does not populate the histogram
assert!(!metrics.poll_count_histogram_enabled());
for n in 0..metrics.num_workers() {
for i in 0..10 {
assert_eq!(0, metrics.poll_count_histogram_bucket_count(n, i));
}
}
}
#[test]
fn worker_poll_count_his... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 281 | 340 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:9 | }
});
drop(rt);
let num_workers = metrics.num_workers();
let num_buckets = metrics.poll_count_histogram_num_buckets();
assert!(metrics.poll_count_histogram_enabled());
assert_eq!(num_buckets, 3);
let n = (0..num_workers)
.flat_map(|i| (0..num_bucket... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 321 | 380 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:10 | .enable_all()
.enable_metrics_poll_count_histogram()
.metrics_poll_count_histogram_scale(tokio::runtime::HistogramScale::Log)
.metrics_poll_count_histogram_buckets(3)
.metrics_poll_count_histogram_resolution(us(50))
.build()
.unwrap();
let metrics = rt.metrics();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 361 | 420 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:11 | }
}
#[test]
fn worker_total_busy_duration() {
const N: usize = 5;
let zero = Duration::from_millis(0);
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
for _ in 0..N {
tokio::spawn(async {
tokio::task::yield_now().await;
}... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 401 | 460 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:12 | for i in 0..metrics.num_workers() {
assert!(zero < metrics.worker_total_busy_duration(i));
}
}
#[test]
fn worker_local_schedule_count() {
let rt = current_thread();
let metrics = rt.metrics();
rt.block_on(async {
tokio::spawn(async {}).await.unwrap();
});
drop(rt);
assert_e... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 441 | 500 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:13 | // Only applies to the threaded worker
let rt = threaded();
let metrics = rt.metrics();
rt.block_on(async {
// Move to the runtime
tokio::spawn(async {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
// First, we ... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 481 | 540 |
tokio-rs/tokio:tokio/tests/rt_unstable_metrics.rs:14 | assert_eq!(1, n);
}
#[test]
fn injection_queue_depth_current_thread() {
use std::thread;
let rt = current_thread();
let handle = rt.handle().clone();
let metrics = rt.metrics();
thread::spawn(move || {
handle.spawn(async {});
})
.join()
.unwrap();
assert_eq!(1, metrics.in... | rust | rust | testsuite | tokio-rs/tokio | tokio/tests/rt_unstable_metrics.rs | MIT | 1be8a8e691f48accda58874bf3a9241cea54daf4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8a8e691f48accda58874bf3a9241cea54daf4/tokio/tests/rt_unstable_metrics.rs | 521 | 580 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.