Skip to content

Commit

Permalink
auto merge of #13921 : TeXitoi/rust/shootout-spectralnorm-tweaks, r=a…
Browse files Browse the repository at this point in the history
…lexcrichton

- using libgreen to optimize CPU usage
- less tasks to limit wasted resources

Here, on a one core 2 threads CPU, new version is ~1.2 faster.  May
be better with more core.
  • Loading branch information
bors committed May 4, 2014
2 parents d8e5d27 + 2acab61 commit 5956939
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test/bench/shootout-spectralnorm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(phase)]
#[phase(syntax)] extern crate green;
extern crate sync;

use std::from_str::FromStr;
Expand All @@ -16,6 +18,8 @@ use std::cmp::min;
use std::os;
use sync::{Arc, RWLock};

green_start!(main)

fn A(i: uint, j: uint) -> f64 {
((i + j) * (i + j + 1) / 2 + i + 1) as f64
}
Expand All @@ -38,7 +42,7 @@ fn mult(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>,
let (tx, rx) = channel();

let len = out.read().len();
let chunk = len / 100 + 1;
let chunk = len / 20 + 1;
for chk in count(0, chunk) {
if chk >= len {break;}
let tx = tx.clone();
Expand Down

0 comments on commit 5956939

Please sign in to comment.