source: benchmark/mutexC/rust.rs @ 9e63a2b

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 9e63a2b was 51493a4, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

start directory for full-contention mutex tests

  • Property mode set to 100644
File size: 547 bytes
Line 
1use std::env;
2use std::process;
3use std::sync::Mutex;
4use std::time::Instant;
5
6fn call( lock : & Mutex<u32> ) {
7        let _ = lock.lock();
8}
9
10fn 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 lock = Mutex::new(0);
17
18        let start = Instant::now();
19        for _ in 1..times {
20                call( &lock );
21        }
22        let duration = start.elapsed() / times;
23        println!( "{:?}", duration.as_nanos() )
24}
25
26// rustc -C opt-level=3 rust.rs
Note: See TracBrowser for help on using the repository browser.