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.792.7964,392493  0% 1% 2% 100%
5,000,00027.1727.1960,300493  0% 1% 1% 100%
50,000,000270.80271.0045,964493  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.


rustc 1.0.0-alpha.2 (522d09dfe 2015-02-19) (built 2015-02-19)

 thread-ring Rust program source code

// The Computer Language Benchmarks Game
// contributed by the Rust Project Developers
// contributed by TeXitoi

#![feature(std_misc, os, env)]

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

fn start(n_tasks: i32, token: i32) {
    let (tx, mut rx) = channel();
    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(Thread::scoped(move|| roundtrip(i, tx, cur_rx)));
    let _guard = Thread::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);
        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())
    let n_tasks =
        .and_then(|s| s.into_string().ok())
        .and_then(|n| n.parse().ok())
    start(n_tasks, token);

 make, command-line, and program output logs

Sat, 21 Feb 2015 21:04:06 GMT

/usr/local/src/rust/bin/rustc -C opt-level=3 -C target-cpu=core2 -C lto -o threadring.rust_run 19:35 warning: use of deprecated item: use module-level free fucntion, #[warn(deprecated)] on by default         guards.push(Thread::scoped(move|| roundtrip(i, tx, cur_rx)));
                                     ^~~~~~~~~~~~~~ 21:32 warning: use of deprecated item: use module-level free fucntion, #[warn(deprecated)] on by default     let _guard = Thread::scoped(move|| roundtrip(1, tx, rx));
                                  ^~~~~~~~~~~~~~ 7:31 warning: unstable feature #![feature(std_misc, os, env)]
note: this feature may not be used in the beta release channel
10.60s to complete and log all make actions

./threadring.rust_run 50000000


Revised BSD license

  Home   Conclusions   License   Play