1 | //! Benchmark spawning a task onto the basic and threaded Tokio executors. |
2 | //! This essentially measure the time to enqueue a task in the local and remote |
3 | //! case. |
4 | |
5 | use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
6 | |
7 | fn time_now_current_thread(c: &mut Criterion) { |
8 | let rt = tokio::runtime::Builder::new_current_thread() |
9 | .enable_time() |
10 | .build() |
11 | .unwrap(); |
12 | |
13 | c.bench_function("time_now_current_thread" , |b| { |
14 | b.iter(|| { |
15 | rt.block_on(async { |
16 | black_box(tokio::time::Instant::now()); |
17 | }) |
18 | }) |
19 | }); |
20 | } |
21 | |
22 | criterion_group!(time_now, time_now_current_thread); |
23 | |
24 | criterion_main!(time_now); |
25 | |