Last change
on this file since 16e6905 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:
607 bytes
|
Line | |
---|
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 = 50000000; |
---|
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 | let th = thread::spawn( move || { |
---|
14 | for _ in 1..times { |
---|
15 | thread::yield_now(); |
---|
16 | } |
---|
17 | }); |
---|
18 | th.join().unwrap(); |
---|
19 | let duration = start.elapsed() / times; |
---|
20 | println!( "{:?}", duration.as_nanos() ) |
---|
21 | } |
---|
22 | |
---|
23 | |
---|
24 | // Local Variables: // |
---|
25 | // tab-width: 4 // |
---|
26 | // compile-command: "rustc -C opt-level=3 rust_thrd.rs" // |
---|
27 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.