2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-16 18:59:55 +00:00
async-std/benches/task_local.rs

21 lines
330 B
Rust
Raw Normal View History

#![feature(test)]
2019-08-08 12:44:48 +00:00
extern crate test;
use async_std::task;
use async_std::task_local;
use test::{black_box, Bencher};
#[bench]
fn get(b: &mut Bencher) {
task_local! {
static VAL: u64 = 1;
}
let mut sum = 0;
task::block_on(async {
b.iter(|| VAL.with(|v| sum += v));
});
black_box(sum);
}