performance measurements

Each table row shows performance measurements for this Rust program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
5000.140.14?492  0% 0% 7% 100%
3,0004.684.684,792492  0% 1% 1% 100%
5,50015.6915.704,916492  1% 0% 3% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read spectral-norm benchmark to see what this program should do.

 notes

rustc 0.11.0 (aa1163b92de7717eb7c5eba002b4012e0574a7fe 2014-06-27 12:50:16 -0700)

 spectral-norm Rust program source code

// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by Mikhail Ivko
// algorithm is a copy from Ledrug's et C code

use std::from_str::FromStr;
use std::iter::AdditiveIterator;

fn a_elem(i: uint, j: uint) -> f64 {
    1.0 / (((i+j) * (i+j+1) / 2 + i + 1) as f64)
}

fn dot(v: &[f64], u: &[f64]) -> f64 {
    v.iter().zip(u.iter()).map(|(&a, &b)| a*b).sum()
}

fn mult_av(v: &[f64]) -> Vec<f64> {
    Vec::from_fn(v.len(), |i|
        range(0, v.len()).zip(v.iter()).map(|(j, &vval)|
            a_elem(i, j)*vval).sum())
}

fn mult_atv(v: &[f64]) -> Vec<f64> {
    Vec::from_fn(v.len(), |i|
        range(0, v.len()).zip(v.iter()).map(|(j, &vval)|
            a_elem(j, i)*vval).sum())
}

fn mult_atav(v: &[f64]) -> Vec<f64> {
    mult_atv(mult_av(v).as_slice())
}

fn main() {
    let args = std::os::args();
    let args = args.as_slice();
    let n = if args.len() < 2 {
        2000
    } else {
        FromStr::from_str(args[1].as_slice()).unwrap()
    };
    let n = if n % 2 != 0 { n + 1 } else { n };

    let (u, v) = range(0, 10u)
        .fold((Vec::from_elem(n, 1f64), Vec::new()), |(u, _), _| {
            let tmp = mult_atav(u.as_slice());
            (mult_atav(tmp.as_slice()), tmp)
        });

    println!("{:.9}",
        (dot(u.as_slice(), v.as_slice())/dot(v.as_slice(), v.as_slice()))
            .sqrt());
}

 make, command-line, and program output logs

Tue, 09 Sep 2014 17:00:42 GMT

MAKE:
/usr/local/src/rust-0.11.0-x86_64-unknown-linux-gnu/bin/rustc --opt-level=3 spectralnorm.rs -o spectralnorm.rust_run
rm spectralnorm.rs
1.10s to complete and log all make actions

COMMAND LINE:
./spectralnorm.rust_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play