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
500,0002.622.6360,172464  1% 0% 0% 100%
5,000,00025.7825.8043,780464  2% 1% 1% 100%
50,000,000250.34250.4641,736464  0% 1% 1% 100%

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

Read thread-ring benchmark to see what this program should do.

 notes

rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)

 thread-ring Rust program source code

// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by the Rust Project Developers
// contributed by TeXitoi

use std::sync::mpsc::{channel, Sender, Receiver};
use std::thread::scoped;

fn start(n_tasks: i32, token: i32) {
    let (tx, mut rx) = channel();
    tx.send(token).unwrap();
    let mut guards = Vec::with_capacity(n_tasks as usize);
    for i in 2 .. n_tasks + 1 {
        let (tx, next_rx) = channel();
        let cur_rx = std::mem::replace(&mut rx, next_rx);
        guards.push(scoped(move|| roundtrip(i, tx, cur_rx)));
    }
    let _guard = scoped(move|| roundtrip(1, tx, rx));
}

fn roundtrip(id: i32, tx: Sender<i32>, rx: Receiver<i32>) {
    for token in rx.iter() {
        if token == 1 {
            println!("{}", id);
            break;
        }
        tx.send(token - 1).unwrap();
    }
}

fn main() {
    let args = &mut std::env::args_os();
    let token = args.skip(1).next()
        .and_then(|s| s.into_string().ok())
        .and_then(|n| n.parse().ok())
        .unwrap_or(1000);
    let n_tasks = args.next()
        .and_then(|s| s.into_string().ok())
        .and_then(|n| n.parse().ok())
        .unwrap_or(503);
    start(n_tasks, token);
}

 make, command-line, and program output logs

Tue, 07 Apr 2015 20:10:07 GMT

MAKE:
/usr/local/src/rust-1.0.0-beta/rustc/bin/rustc -C opt-level=3 -C target-cpu=core2 -C lto threadring.rs -o threadring.rust_run
rm threadring.rs
12.18s to complete and log all make actions

COMMAND LINE:
./threadring.rust_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play