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