mirror of
https://github.com/plasma-umass/coz.git
synced 2024-09-11 04:55:25 +03:00
Added black_box, currently unused; changed computation.
This commit is contained in:
parent
76699e857b
commit
5e0cd59033
@ -1,18 +1,39 @@
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
use coz;
|
use coz;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
#[no_mangle]
|
|
||||||
pub fn a_first_fn() {
|
fn black_box<T>(dummy: T) -> T {
|
||||||
for _x in 0..2000000 {}
|
unsafe {
|
||||||
|
std::ptr::read_volatile(&dummy)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn b_second_fn() {
|
pub fn a_first_fn() -> i64 {
|
||||||
for _y in 0..1900000 {}
|
let mut v: i64 = 0;
|
||||||
|
for x in 0..200000000 {
|
||||||
|
v += x * x;
|
||||||
|
v -= x * x;
|
||||||
|
v += x * x;
|
||||||
|
v -= x * x;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn b_second_fn() -> i64 {
|
||||||
|
let mut v: i64 = 0;
|
||||||
|
for x in 0..100000000 {
|
||||||
|
v += x * x;
|
||||||
|
v -= x * x;
|
||||||
|
v += x * x;
|
||||||
|
v -= x * x;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
for _n in 1..1000 {
|
for _n in 1..100 {
|
||||||
let handle1 = thread::spawn(|| a_first_fn());
|
let handle1 = thread::spawn(|| a_first_fn());
|
||||||
let handle2 = thread::spawn(|| b_second_fn());
|
let handle2 = thread::spawn(|| b_second_fn());
|
||||||
handle1.join().unwrap();
|
handle1.join().unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user