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_metrics.rs:18
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); assert_eq!(metrics.io_driver_fd_deregistered_count(), 0); d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
d085260ee02f25c4a56cfcd9d0b57fa15840aebb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d085260ee02f25c4a56cfcd9d0b57fa15840aebb/tokio/tests/rt_metrics.rs
681
733
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![allow(unknown_lints, unexpected_cfgs)] #![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))] use std::future::Future; use std::sync::{Arc, Mutex}; use std::task::Poll; use tokio::macros::support::poll_fn; use tokio::runtime::Runtime; use tokio::task::consume_budget; use...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
rx2.recv().unwrap(); }); }); rx1.recv().unwrap(); // Spawn many tasks for _ in 0..300 { tokio::spawn(async {}); } tx2.send(()).unwrap(); }) .await .unwrap(); }); drop(rt); let ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
let rt = threaded(); let handle = rt.handle().clone(); let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); let (tx3, rx3) = std::sync::mpsc::channel(); let rx3 = Arc::new(Mutex::n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
2a0df5fb05ae1a624fe2f6db756190f41812214b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(target_os = "wasi")))] use std::future::Future; use std::sync::{Arc, Mutex}; use std::task::Poll; use tokio::macros::support::poll_fn; use tokio::runtime::Runtime; use tokio::task::consume_budget; use tokio::time::{self, Duration}; #[test] f...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2
// for another second. We don't always wait for a whole second since we want // the test suite to finish quickly. // // Note that the timeout for idle threads to be killed is 10 seconds. if 0 == rt.metrics().num_idle_blocking_threads() { rt.block_on(async { time::sleep(Duration::from...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
41
100
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3
assert_eq!(0, rt.metrics().blocking_queue_depth()); } #[test] fn active_tasks_count() { let rt = current_thread(); let metrics = rt.metrics(); assert_eq!(0, metrics.active_tasks_count()); rt.spawn(async move { assert_eq!(1, metrics.active_tasks_count()); }); let rt = threaded(); le...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
81
140
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
let task = thread::spawn(move || { handle.spawn(async { // DO nothing }) }) .join() .unwrap(); rt.block_on(task).unwrap(); assert_eq!(1, rt.metrics().remote_schedule_count()); } #[test] fn worker_park_count() { let rt = current_thread(); let metrics = rt.metric...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
}); }); 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_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
let rt = threaded(); let handle = rt.handle().clone(); let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); let (tx3, rx3) = std::sync::mpsc::channel(); let rx3 = Arc::new(Mutex::n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15
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(); let m...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
561
620
tokio-rs/tokio:tokio/tests/rt_metrics.rs:16
.sum(); assert_eq!(n, N); tx2.send(()).unwrap(); }) .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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
601
660
tokio-rs/tokio:tokio/tests/rt_metrics.rs:17
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 { tokio::join!( poll_fn(|cx| loop...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
641
700
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
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::connect...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
681
740
tokio-rs/tokio:tokio/tests/rt_metrics.rs:19
} 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_lifo_slot() .enable_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
5712aaf995b244226aff78ed4a13bf6c9105f3ab
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5712aaf995b244226aff78ed4a13bf6c9105f3ab/tokio/tests/rt_metrics.rs
721
742
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
let task = thread::spawn(move || { handle.spawn(async { // DO nothing }) }) .join() .unwrap(); rt.block_on(task).unwrap(); assert_eq!(1, rt.metrics().remote_schedule_count()); } #[test] fn worker_park_count() { let rt = current_thread(); let metrics = rt.metric...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
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_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
}) .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() { // Sync sleep std::thr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7
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)) .sum(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
241
300
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8
.metrics_poll_count_histogram_buckets(3) .metrics_poll_count_histogram_resolution(Duration::from_millis(50)) .build() .unwrap(), tokio::runtime::Builder::new_multi_thread() .worker_threads(2) .enable_all() .enable_metrics_poll_count_histogr...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
281
340
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9
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_poll_count_histogram_buckets(3) .metrics...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
321
380
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10
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)) .build() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
361
420
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
}); 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 .unwrap...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
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_schedule_count(i)) .sum(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
441
500
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
}); 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()) .map(|i| ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
let handle = rt.handle().clone(); let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); let (tx3, rx3) = std::sync::mpsc::channel(); let rx3 = Arc::new(Mutex::new(rx3)); rt.spawn(a...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15
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(); let metrics = rt.metrics(); rt.block_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
561
620
tokio-rs/tokio:tokio/tests/rt_metrics.rs:16
assert_eq!(n, N); tx2.send(()).unwrap(); }) .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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
601
660
tokio-rs/tokio:tokio/tests/rt_metrics.rs:17
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 { tokio::join!( poll_fn(|cx| loop { if did_yield...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
641
700
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
} #[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::connect("google.com:80"); let stream = rt.block_on(async mov...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
47a5fe3a12cb8f92a776fe2469899a8cdc338a46
github
async-runtime
https://github.com/tokio-rs/tokio/blob/47a5fe3a12cb8f92a776fe2469899a8cdc338a46/tokio/tests/rt_metrics.rs
681
740
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
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_metrics.rs
MIT
e6720f985df660a058a4228c6cb96c77d9c0b2a8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6720f985df660a058a4228c6cb96c77d9c0b2a8/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
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::connect...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
e6720f985df660a058a4228c6cb96c77d9c0b2a8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6720f985df660a058a4228c6cb96c77d9c0b2a8/tokio/tests/rt_metrics.rs
681
734
tokio-rs/tokio:tokio/tests/rt_metrics.rs:19
.unwrap() } fn threaded() -> Runtime { tokio::runtime::Builder::new_multi_thread() .worker_threads(2) .enable_all() .build() .unwrap() } fn us(n: u64) -> Duration { Duration::from_micros(n) }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
e6720f985df660a058a4228c6cb96c77d9c0b2a8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e6720f985df660a058a4228c6cb96c77d9c0b2a8/tokio/tests/rt_metrics.rs
721
734
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
let rt = threaded(); 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| met...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
441
500
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
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()) .map(|i| metrics.worker_ov...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); let (tx3, rx3) = std::sync::mpsc::channel(); let rx3 = Arc::new(Mutex::new(rx3)); rt.spawn(async move { rx1.recv().unwrap() }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15
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(); let metrics = rt.metrics(); rt.block_on(async move { // ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
561
620
tokio-rs/tokio:tokio/tests/rt_metrics.rs:16
assert_eq!(n, N); tx2.send(()).unwrap(); }) .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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
601
660
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
#[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::connect("google.com:80"); let stream = rt.block_on(async move {...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
681
731
tokio-rs/tokio:tokio/tests/rt_metrics.rs:19
fn threaded() -> Runtime { tokio::runtime::Builder::new_multi_thread() .worker_threads(2) .enable_all() .build() .unwrap() } fn us(n: u64) -> Duration { Duration::from_micros(n) }
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
6cb106c3538cf527495ef5491c088d1365b14c8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6cb106c3538cf527495ef5491c088d1365b14c8e/tokio/tests/rt_metrics.rs
721
731
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
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_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
// Blocking receive on the channel. 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() { const N: u64...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7
tokio::spawn(async {}).await.unwrap(); } }); drop(rt); // Account for the `block_on` task let n = (0..metrics.num_workers()) .map(|i| metrics.worker_poll_count(i)) .sum(); assert_eq!(N, n); // Does not populate the histogram assert!(!metrics.poll_count_histogram_ena...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
241
300
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8
.build() .unwrap(), ]; 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_buc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
281
340
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9
assert_eq!(metrics.poll_count_histogram_bucket_range(0), us(0)..us(50)); assert_eq!( metrics.poll_count_histogram_bucket_range(1), us(50)..us(100) ); assert_eq!(metrics.poll_count_histogram_bucket_range(2), us(100)..max); let rt = tokio::runtime::Builder::new_current_thread() .e...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
321
380
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10
.metrics_poll_count_histogram_buckets(3) .metrics_poll_count_histogram_resolution(Duration::from_millis(50)) .build() .unwrap(), ]; for rt in rts { let metrics = rt.metrics(); assert!(!metrics.poll_count_histogram_enabled()); } } #[test] fn worker_total_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
361
420
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
tokio::spawn(async { tokio::task::yield_now().await; }) .await .unwrap(); } }); drop(rt); for i in 0..metrics.num_workers() { assert!(zero < metrics.worker_total_busy_duration(i)); } } #[test] fn worker_local_schedule_count() { l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
.map(|i| metrics.worker_local_schedule_count(i)) .sum(); assert_eq!(2, n); 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 ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
441
500
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
drop(rt); let n: u64 = (0..metrics.num_workers()) .map(|i| metrics.worker_overflow_count(i)) .sum(); assert_eq!(1, n); } #[test] fn injection_queue_depth() { use std::thread; let rt = current_thread(); let handle = rt.handle().clone(); let metrics = rt.metrics(); thread:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
let rx = rx3.clone(); rt.spawn(async move { rx.lock().unwrap().recv().unwrap(); }); } thread::spawn(move || { handle.spawn(async {}); }) .join() .unwrap(); let n = metrics.injection_queue_depth(); assert!(1 <= n, "{}", n); assert!(15 >= n, "{}", n); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
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_metrics.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/rt_metrics.rs
681
718
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))] use std::future::Future; use std::sync::{Arc, Mutex}; use std::task::Poll; use tokio::macros::support::poll_fn; use tokio::runtime::Runtime; use tokio::task::consume_budget; use tokio::time::{self, Duration}; #[test] fn num_wo...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
3a94eb089343e1efa9563b91e13c79a0e61b2364
github
async-runtime
https://github.com/tokio-rs/tokio/blob/3a94eb089343e1efa9563b91e13c79a0e61b2364/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
drop(rt); let n: u64 = (0..metrics.num_workers()) .map(|i| metrics.worker_overflow_count(i)) .sum(); assert_eq!(1, n); } #[test] fn injection_queue_depth() { use std::thread; let rt = current_thread(); let handle = rt.handle().clone(); let metrics = rt.metrics(); thread:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
.unwrap(); let n = metrics.injection_queue_depth(); assert!(1 <= n, "{}", n); assert!(3 >= n, "{}", n); tx1.send(()).unwrap(); tx2.send(()).unwrap(); } #[test] fn worker_local_queue_depth() { const N: usize = 100; let rt = current_thread(); let metrics = rt.metrics(); rt.block_on...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/tests/rt_metrics.rs
521
580
tokio-rs/tokio:tokio/tests/rt_metrics.rs:15
tokio::spawn(async {}); 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(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/tests/rt_metrics.rs
561
620
tokio-rs/tokio:tokio/tests/rt_metrics.rs:17
let fut = consume_budget(); tokio::pin!(fut); if fut.poll(cx).is_pending() { did_yield_2 = true; return Poll::Pending; } }) ) }); assert_eq!(1, rt.metrics().budget_forced_yield_count()); } #[cfg(any(ta...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/tests/rt_metrics.rs
641
700
tokio-rs/tokio:tokio/tests/rt_metrics.rs:18
let stream = tokio::net::TcpStream::connect("google.com:80"); let _stream = rt.block_on(async move { stream.await.unwrap() }); assert_eq!(metrics.io_driver_ready_count(), 1); } fn current_thread() -> Runtime { tokio::runtime::Builder::new_current_thread() .enable_all() .build() .un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c84d0a14b189c45da8f5e963fd3a83790ec92f8e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c84d0a14b189c45da8f5e963fd3a83790ec92f8e/tokio/tests/rt_metrics.rs
681
704
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
// Blocking receive on the channel. 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() { const N: u64...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7
.map(|i| metrics.worker_poll_count(i)) .sum(); assert_eq!(N, n); } #[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:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
241
300
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8
}); 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(); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
281
340
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9
#[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::channel(); let (tx2, rx2) = std::sync::mp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
321
380
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10
assert_eq!(1, n); } #[test] fn injection_queue_depth() { 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_d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
361
420
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
tx1.send(()).unwrap(); tx2.send(()).unwrap(); } #[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...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
} }) ) }); 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_metrics.rs
MIT
1d785fd66fce4a9125c6f0c403dfe1921d011539
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1d785fd66fce4a9125c6f0c403dfe1921d011539/tokio/tests/rt_metrics.rs
521
574
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2
// for another second. We don't always wait for a whole second since we want // the test suite to finish quickly. // // Note that the timeout for idle threads to be killed is 10 seconds. if 0 == rt.metrics().num_idle_blocking_threads() { rt.block_on(async { time::sleep(Duration::from...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
41
100
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3
assert_eq!(0, rt.metrics().blocking_queue_depth()); } #[test] 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()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
81
140
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
rt.block_on(async { time::sleep(Duration::from_millis(1)).await; }); drop(rt); 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 <= met...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
fn worker_steal_count() { // This metric only applies to the multi-threaded runtime. // // We use a blocking channel to backup one worker thread. use std::sync::mpsc::channel; let rt = threaded(); let metrics = rt.metrics(); rt.block_on(async { let (tx, rx) = channel(); //...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
fn worker_poll_count() { const N: u64 = 5; let rt = current_thread(); let metrics = rt.metrics(); rt.block_on(async { for _ in 0..N { tokio::spawn(async {}).await.unwrap(); } }); drop(rt); assert_eq!(N, metrics.worker_poll_count(0)); let rt = threaded(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:7
tokio::spawn(async { tokio::task::yield_now().await; }) .await .unwrap(); } }); drop(rt); assert!(zero < metrics.worker_total_busy_duration(0)); let rt = threaded(); let metrics = rt.metrics(); rt.block_on(async { for _ in 0...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
241
300
tokio-rs/tokio:tokio/tests/rt_metrics.rs:8
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 tokio::spawn(async { tokio::spawn(async {}).await.unwrap(); }) ....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
281
340
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9
}); // Bump the next-run spawn tokio::spawn(async {}); rx1.recv().unwrap(); // Spawn many tasks for _ in 0..300 { tokio::spawn(async {}); } tx2.send(()).unwrap(); }) .await .unwrap(); }); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
321
380
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10
assert_eq!(1, metrics.injection_queue_depth()); let rt = threaded(); let handle = rt.handle().clone(); let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); rt.spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
361
420
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
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::channel(); // First, we need to block the other worker un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
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 { retu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
441
500
tokio-rs/tokio:tokio/tests/rt_metrics.rs:13
if did_yield_1 { return Poll::Ready(()); } let fut = consume_budget(); tokio::pin!(fut); if fut.poll(cx).is_pending() { did_yield_1 = true; return Poll::Pending; } })...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
481
540
tokio-rs/tokio:tokio/tests/rt_metrics.rs:14
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_deregistered_count(), 1); assert_eq!(metrics.io_driver_fd_registered_coun...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
52da177dea169aa9f3dac6b1465fa5229a9615bb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/tests/rt_metrics.rs
521
557
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))] use std::sync::{Arc, Mutex}; use tokio::runtime::Runtime; use tokio::time::{self, Duration}; #[test] fn num_workers() { let rt = current_thread(); assert_eq!(1, rt.metrics().num_workers()); let rt = threaded(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2
if 0 == rt.metrics().num_idle_blocking_threads() { rt.block_on(async { time::sleep(Duration::from_secs(1)).await; }); } assert_eq!(1, rt.metrics().num_idle_blocking_threads()); } #[test] fn blocking_queue_depth() { let rt = tokio::runtime::Builder::new_current_thread() ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
41
100
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
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_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
use std::sync::mpsc::channel; let rt = threaded(); 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 tokio::spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
let metrics = rt.metrics(); rt.block_on(async { for _ in 0..N { tokio::spawn(async {}).await.unwrap(); } }); drop(rt); assert_eq!(N, metrics.worker_poll_count(0)); let rt = threaded(); let metrics = rt.metrics(); rt.block_on(async { for _ in 0..N { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:9
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()) .map(|i| metrics.worker_ov...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
321
380
tokio-rs/tokio:tokio/tests/rt_metrics.rs:10
let metrics = rt.metrics(); // First we need to block the runtime workers let (tx1, rx1) = std::sync::mpsc::channel(); let (tx2, rx2) = std::sync::mpsc::channel(); rt.spawn(async move { rx1.recv().unwrap() }); rt.spawn(async move { rx2.recv().unwrap() }); thread::spawn(move || { handl...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
361
420
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
// 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. tokio::spawn(async move { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
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); assert_eq!(metrics.io_driver_fd_deregistered_count(), 0); d...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
c6552c5680fa14105547cfbbc26b26d67197b64e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/tests/rt_metrics.rs
441
481
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
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_metrics.rs
MIT
6b3727d5804bbe08f7e5230949ee809732cf1010
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6b3727d5804bbe08f7e5230949ee809732cf1010/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))] use std::sync::{Arc, Mutex}; use tokio::runtime::Runtime; use tokio::time::{self, Duration}; #[test] fn num_workers() { let rt = current_thread(); assert_eq!(1, rt.metrics().num_workers()); let rt = threaded(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2
.max_blocking_threads(1) .build() .unwrap(); assert_eq!(0, rt.metrics().blocking_queue_depth()); let ready = Arc::new(Mutex::new(())); let guard = ready.lock().unwrap(); let ready_cloned = ready.clone(); let wait_until_ready = move || { let _unused = ready_cloned.lock().un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
41
100
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3
rt.block_on(task).unwrap(); assert_eq!(1, rt.metrics().remote_schedule_count()); let rt = threaded(); let handle = rt.handle().clone(); let task = thread::spawn(move || { handle.spawn(async { // DO nothing }) }) .join() .unwrap(); rt.block_on(task).unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
81
140
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
fn worker_noop_count() { // There isn't really a great way to generate no-op parks as they happen as // false-positive events under concurrency. let rt = current_thread(); let metrics = rt.metrics(); rt.block_on(async { time::sleep(Duration::from_millis(1)).await; }); drop(rt); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
121
180
tokio-rs/tokio:tokio/tests/rt_metrics.rs:5
}); // Spawn a task that bumps the previous task out of the "next // scheduled" slot. tokio::spawn(async {}); // Blocking receive on the channel. rx.recv().unwrap(); }) .await .unwrap(); }); drop(rt); let n: u64 = (0..me...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
161
220
tokio-rs/tokio:tokio/tests/rt_metrics.rs:6
tokio::spawn(async {}).await.unwrap(); } }); drop(rt); // Account for the `block_on` task let n = (0..metrics.num_workers()) .map(|i| metrics.worker_poll_count(i)) .sum(); assert_eq!(N, n); } #[test] fn worker_total_busy_duration() { const N: usize = 5; let zero = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
201
260
tokio-rs/tokio:tokio/tests/rt_metrics.rs:11
tokio::spawn(async {}); 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(); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
401
460
tokio-rs/tokio:tokio/tests/rt_metrics.rs:12
} #[cfg(any(target_os = "linux", target_os = "macos"))] #[test] fn io_driver_ready_count() { let rt = current_thread(); let metrics = rt.metrics(); let stream = tokio::net::TcpStream::connect("google.com:80"); let _stream = rt.block_on(async move { stream.await.unwrap() }); assert_eq!(metrics.io_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
808d52563e234769d2fc296ff17ca12173735d9e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/808d52563e234769d2fc296ff17ca12173735d9e/tokio/tests/rt_metrics.rs
441
468
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3
rt.block_on(task).unwrap(); assert_eq!(1, rt.metrics().remote_schedule_count()); let rt = threaded(); let handle = rt.handle().clone(); let task = thread::spawn(move || { handle.spawn(async { // DO nothing }) }) .join() .unwrap(); rt.block_on(task).unwrap()...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
23fdd32b0180f6a0f65040170755901ea6f48056
github
async-runtime
https://github.com/tokio-rs/tokio/blob/23fdd32b0180f6a0f65040170755901ea6f48056/tokio/tests/rt_metrics.rs
81
140
tokio-rs/tokio:tokio/tests/rt_metrics.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", tokio_unstable, not(tokio_wasi)))] use tokio::runtime::Runtime; use tokio::time::{self, Duration}; #[test] fn num_workers() { let rt = current_thread(); assert_eq!(1, rt.metrics().num_workers()); let rt = threaded(); assert_eq!(2, rt.metrics().n...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
ec66a92b016914f2ead483bada32ffe696a2fd3a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs
1
60
tokio-rs/tokio:tokio/tests/rt_metrics.rs:2
.join() .unwrap(); rt.block_on(task).unwrap(); assert_eq!(1, rt.metrics().remote_schedule_count()); } #[test] fn worker_park_count() { let rt = current_thread(); let metrics = rt.metrics(); rt.block_on(async { time::sleep(Duration::from_millis(1)).await; }); drop(rt); asse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
ec66a92b016914f2ead483bada32ffe696a2fd3a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs
41
100
tokio-rs/tokio:tokio/tests/rt_metrics.rs:3
let rt = threaded(); let metrics = rt.metrics(); rt.block_on(async { time::sleep(Duration::from_millis(1)).await; }); drop(rt); assert!(1 <= metrics.worker_noop_count(0)); assert!(1 <= metrics.worker_noop_count(1)); } #[test] fn worker_steal_count() { // This metric only applies to ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/rt_metrics.rs
MIT
ec66a92b016914f2ead483bada32ffe696a2fd3a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs
81
140
tokio-rs/tokio:tokio/tests/rt_metrics.rs:4
}); 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() { const N: u64 = 5; 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_metrics.rs
MIT
ec66a92b016914f2ead483bada32ffe696a2fd3a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ec66a92b016914f2ead483bada32ffe696a2fd3a/tokio/tests/rt_metrics.rs
121
180