Skip to content

Commit

Permalink
shootout-spectralnorm tweaks
Browse files Browse the repository at this point in the history
- 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
TeXitoi committed May 3, 2014
1 parent e0d261e commit 2acab61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test/bench/shootout-spectralnorm.rs
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

5 comments on commit 2acab61

@bors
Copy link
Contributor

@bors bors commented on 2acab61 May 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at TeXitoi@2acab61

@bors
Copy link
Contributor

@bors bors commented on 2acab61 May 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging TeXitoi/rust/shootout-spectralnorm-tweaks = 2acab61 into auto

@bors
Copy link
Contributor

@bors bors commented on 2acab61 May 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeXitoi/rust/shootout-spectralnorm-tweaks = 2acab61 merged ok, testing candidate = 5956939

@bors
Copy link
Contributor

@bors bors commented on 2acab61 May 4, 2014

@bors
Copy link
Contributor

@bors bors commented on 2acab61 May 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5956939

Please sign in to comment.