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
50,0000.730.7827,152748  3% 0% 5% 100%
500,0007.137.2146,220748  0% 1% 1% 100%
5,000,00071.1671.19214,088748  1% 0% 0% 100%

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

Read regex-dna benchmark to see what this program should do.

 notes

rustc 1.0.0-alpha (44a287e6e 2015-01-08 17:03:40 -0800)

 regex-dna Rust program source code

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

extern crate regex;

use std::io;
use regex::{NoExpand, Regex};
use std::sync::{Arc, Future};

macro_rules! regex {
    ($e:expr) => (Regex::new($e).unwrap())
}

fn count_matches(seq: &str, variant: &Regex) -> i32 {
    let mut n = 0;
    for _ in variant.find_iter(seq) {
        n += 1;
    }
    n
}

fn main() {
    let mut rdr = io::stdin();
    let mut seq = rdr.read_to_string().unwrap();
    let ilen = seq.len();

    seq = regex!(">[^\n]*\n|\n").replace_all(&*seq, NoExpand(""));
    let seq_arc = Arc::new(seq.clone()); // copy before it moves
    let clen = seq.len();

    let mut seqlen = Future::spawn(move|| {
        let substs = vec![
            (regex!("B"), "(c|g|t)"),
            (regex!("D"), "(a|g|t)"),
            (regex!("H"), "(a|c|t)"),
            (regex!("K"), "(g|t)"),
            (regex!("M"), "(a|c)"),
            (regex!("N"), "(a|c|g|t)"),
            (regex!("R"), "(a|g)"),
            (regex!("S"), "(c|g)"),
            (regex!("V"), "(a|c|g)"),
            (regex!("W"), "(a|t)"),
            (regex!("Y"), "(c|t)"),
        ];
        let mut seq = seq;
        for (re, replacement) in substs.into_iter() {
            seq = re.replace_all(&*seq, NoExpand(replacement));
        }
        seq.len()
    });

    let variants = vec![
        regex!("agggtaaa|tttaccct"),
        regex!("[cgt]gggtaaa|tttaccc[acg]"),
        regex!("a[act]ggtaaa|tttacc[agt]t"),
        regex!("ag[act]gtaaa|tttac[agt]ct"),
        regex!("agg[act]taaa|ttta[agt]cct"),
        regex!("aggg[acg]aaa|ttt[cgt]ccct"),
        regex!("agggt[cgt]aa|tt[acg]accct"),
        regex!("agggta[cgt]a|t[acg]taccct"),
        regex!("agggtaa[cgt]|[acg]ttaccct"),
    ];
    let (mut variant_strs, mut counts) = (vec!(), vec!());
    for variant in variants.into_iter() {
        let seq_arc_copy = seq_arc.clone();
        variant_strs.push(variant.to_string());
        counts.push(Future::spawn(move|| {
            count_matches(&**seq_arc_copy, &variant)
        }));
    }

    for (i, variant) in variant_strs.iter().enumerate() {
        println!("{} {}", variant, counts[i].get());
    }
    println!("");
    println!("{}", ilen);
    println!("{}", clen);
    println!("{}", seqlen.get());
}

 make, command-line, and program output logs

Sat, 10 Jan 2015 22:53:53 GMT

MAKE:
/usr/local/src/rust/bin/rustc -C opt-level=3 -C target-cpu=core2 -C lto regexdna.rs -o regexdna.rust_run
regexdna.rs:7:1: 7:20 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:7 extern crate regex;
              ^~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:19:22: 19:36 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:19     for _ in variant.find_iter(seq) {
                                    ^~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:26:19: 26:28 warning: use of unstable item
regexdna.rs:26     let mut rdr = io::stdin();
                                 ^~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:27:23: 27:39 warning: use of unstable item
regexdna.rs:27     let mut seq = rdr.read_to_string().unwrap();
                                     ^~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:30:34: 30:66 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:30     seq = regex!(">[^\n]*\n|\n").replace_all(&*seq, NoExpand(""));
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:30:53: 30:61 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:30     seq = regex!(">[^\n]*\n|\n").replace_all(&*seq, NoExpand(""));
                                                                   ^~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:50:22: 50:63 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:50             seq = re.replace_all(&*seq, NoExpand(replacement));
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:50:41: 50:49 warning: use of unstable item: use the crates.io `regex` library instead
regexdna.rs:50             seq = re.replace_all(&*seq, NoExpand(replacement));
                                                       ^~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:34:22: 34:35 warning: use of unstable item: futures as-is have yet to be deeply reevaluated with recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time
regexdna.rs:34     let mut seqlen = Future::spawn(move|| {
                                    ^~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:69:35: 69:46 warning: use of unstable item
regexdna.rs:69         variant_strs.push(variant.to_string());
                                                 ^~~~~~~~~~~
note: this feature may not be used in the beta release channel
regexdna.rs:70:21: 70:34 warning: use of unstable item: futures as-is have yet to be deeply reevaluated with recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time
regexdna.rs:70         counts.push(Future::spawn(move|| {
                                   ^~~~~~~~~~~~~
note: this feature may not be used in the beta release channel
rm regexdna.rs
17.27s to complete and log all make actions

COMMAND LINE:
./regexdna.rust_run 0 < regexdna-input5000000.txt

PROGRAM OUTPUT:
agggtaaa|tttaccct 356
[cgt]gggtaaa|tttaccc[acg] 1250
a[act]ggtaaa|tttacc[agt]t 4252
ag[act]gtaaa|tttac[agt]ct 2894
agg[act]taaa|ttta[agt]cct 5435
aggg[acg]aaa|ttt[cgt]ccct 1537
agggt[cgt]aa|tt[acg]accct 1431
agggta[cgt]a|t[acg]taccct 1608
agggtaa[cgt]|[acg]ttaccct 2178

50833411
50000000
66800214

Revised BSD license

  Home   Conclusions   License   Play