ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change
on this file since 75c7252 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
|
Rev | Line | |
---|
[c1dfa4e] | 1 | #![warn(rust_2018_idioms)] |
---|
| 2 | |
---|
| 3 | use tokio::task; |
---|
| 4 | |
---|
| 5 | use std::env; |
---|
| 6 | use std::process; |
---|
| 7 | use std::time::Instant; |
---|
| 8 | |
---|
| 9 | #[tokio::main] |
---|
| 10 | async 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.