summaryrefslogtreecommitdiff
path: root/benches/spawn.rs
blob: 75d059ececc776e4ac06cf1ba330636a08c11510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![feature(test)]

extern crate test;

use smol::future;
use test::Bencher;

#[bench]
fn task_create(b: &mut Bencher) {
    b.iter(|| {
        let _ = async_task::spawn(async {}, drop);
    });
}

#[bench]
fn task_run(b: &mut Bencher) {
    b.iter(|| {
        let (runnable, task) = async_task::spawn(async {}, drop);
        runnable.run();
        future::block_on(task);
    });
}