source: benchmark/creation/rust_tokio_thrd.rs @ 3606fe4

ADTast-experimentalpthread-emulation
Last change on this file since 3606fe4 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: 793 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                let _ : task::JoinHandle<_> = task::spawn(async {
19                        // some work here
20                });
21        }
22        let duration = start.elapsed() / times;
23        println!( "{:?}", duration.as_nanos() )
24}
25
26// https://docs.rs/tokio/0.2.2/tokio/task/struct.JoinHandle.html
27
28// ~/software/rust/tokio/src/main.rs
29// ~/software/rust/tokio/target/release/tokio
30// $ cargo build --release
31// % tokio
32
33// Local Variables: //
34// mode: c++ //
35// tab-width: 4 //
36// End: //
Note: See TracBrowser for help on using the repository browser.