performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load

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

ruby 2.1.5p273 (2014-11-13 revision 48405) [i686-linux]

 regex-dna Ruby #4 program source code

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
#
# Contributed by Aaron Tavistock

class Matcher
  def initialize(label)
    @label = label
    @regex = Regexp.new(label)
    @count = 0
  end
  
  def label
    @label
  end
  
  def increment_on_match(str)
    if str.match(@regex) 
      @count += 1
    end
  end
 
  def results
    %[#{@label} #{@count}] 
  end
end

seq = STDIN.read
origin_len = seq.size

seq.gsub!(/>.*\n|\n/,'')
clean_len = seq.size

matchers = [
  Matcher.new('agggtaaa|tttaccct'),
  Matcher.new('[cgt]gggtaaa|tttaccc[acg]'),
  Matcher.new('a[act]ggtaaa|tttacc[agt]t'),
  Matcher.new('ag[act]gtaaa|tttac[agt]ct'),
  Matcher.new('agg[act]taaa|ttta[agt]cct'),
  Matcher.new('aggg[acg]aaa|ttt[cgt]ccct'),
  Matcher.new('agggt[cgt]aa|tt[acg]accct'),
  Matcher.new('agggta[cgt]a|t[acg]taccct'),
  Matcher.new('agggtaa[cgt]|[acg]ttaccct')
]

aggregate_regex = Regexp.new( matchers.map(&:label).join('|') )
seq.gsub(aggregate_regex) do |match_string|
  matchers.each do |matcher|
    break if matcher.increment_on_match(match_string)
  end
end

replacements = {
  'B' => '(c|g|t)', 
  'D' => '(a|g|t)', 
  'H' => '(a|c|t)', 
  'K' => '(g|t)',
  'M' => '(a|c)', 
  'N' => '(a|c|g|t)', 
  'R' => '(a|g)', 
  'S' => '(c|t)',
  'V' => '(a|c|g)', 
  'W' => '(a|t)', 
  'Y' => '(c|t)'
}
seq.gsub!(Regexp.new(replacements.keys.join('|')), replacements)

puts "#{matchers.map(&:results).join("\n")}\n\n#{origin_len}\n#{clean_len}\n#{seq.size}"

 make, command-line, and program output logs

Tue, 16 Jul 2013 05:12:47 GMT

COMMAND LINE:
/usr/local/src/ruby-2.0.0-p247/ruby regexdna.yarv-4.yarv 0 < regexdna-input50000.txt

UNEXPECTED OUTPUT 

9c9
< agggtaa[cgt]|[acg]ttaccct 18
---
> agggtaa[cgt]|[acg]ttaccct 20

PROGRAM OUTPUT:
agggtaaa|tttaccct 3
[cgt]gggtaaa|tttaccc[acg] 12
a[act]ggtaaa|tttacc[agt]t 43
ag[act]gtaaa|tttac[agt]ct 27
agg[act]taaa|ttta[agt]cct 58
aggg[acg]aaa|ttt[cgt]ccct 16
agggt[cgt]aa|tt[acg]accct 15
agggta[cgt]a|t[acg]taccct 18
agggtaa[cgt]|[acg]ttaccct 18

508411
500000
668262

Revised BSD license

  Home   Conclusions   License   Play