Last change
on this file since 822332e was
b4107c8,
checked in by Peter A. Buhr <pabuhr@…>, 5 years ago
|
update existing benchmarks for changes to bench.h, add new benchmarks in new programming languages
|
-
Property mode set to
100644
|
File size:
594 bytes
|
Rev | Line | |
---|
[b4107c8] | 1 | use std::env; |
---|
| 2 | use std::process; |
---|
| 3 | use std::thread; |
---|
| 4 | use std::time::Instant; |
---|
| 5 | |
---|
| 6 | fn main() { |
---|
| 7 | let mut times : u32 = 250000; |
---|
| 8 | let args: Vec<String> = env::args().collect(); |
---|
| 9 | if args.len() > 2 { process::exit( 1 ); } |
---|
| 10 | if args.len() == 2 { times = args[1].parse().unwrap(); } |
---|
| 11 | |
---|
| 12 | let start = Instant::now(); |
---|
| 13 | for _ in 1..times { |
---|
| 14 | let th = thread::spawn( move || {}); |
---|
| 15 | th.join().unwrap(); |
---|
| 16 | } |
---|
| 17 | let duration = start.elapsed() / times; |
---|
| 18 | println!( "{:?}", duration.as_nanos() ) |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | // Local Variables: // |
---|
| 22 | // mode: c++ // |
---|
| 23 | // tab-width: 4 // |
---|
| 24 | // compile-command: "rustc -C opt-level=3 rust_thrd.rs" // |
---|
| 25 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.