mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-16 10:49:55 +00:00
21 lines
343 B
Rust
21 lines
343 B
Rust
|
#![feature(async_await, test)]
|
||
|
|
||
|
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);
|
||
|
}
|