source: benchmark/ctxswitch/rust_tokio_thrd.rs @ e76fa30

ADTast-experimentalpthread-emulation
Last change on this file since e76fa30 was c1dfa4e, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

add rust/tokio and rust/async-std benchmarks

  • Property mode set to 100644
File size: 675 bytes
Line 
1#![warn(rust_2018_idioms)]
2
3use tokio::task;
4
5use std::env;
6use std::process;
7use std::time::Instant;
8
9#[tokio::main]
10async fn main() {
11        let mut times : u32 = 50000000;
12        let args: Vec<String> = env::args().collect();
13        if args.len() > 2 { process::exit( 1 ); }
14        if args.len() == 2 { times = args[1].parse().unwrap(); }
15
16        let start = Instant::now();
17        for _ in 1..times {
18                task::yield_now().await;
19        }
20        let duration = start.elapsed() / times;
21        println!( "{:?}", duration.as_nanos() )
22}
23
24// ~/software/rust/tokio/src/main.rs
25// ~/software/rust/tokio/target/release/tokio
26// $ cargo build --release
27// % tokio
28
29// Local Variables: //
30// mode: c++ //
31// tab-width: 4 //
32// End: //
Note: See TracBrowser for help on using the repository browser.