Sha256: b79ffe03942c75d3ca6a8dccc85f9b62b8074ca0b11f94cb1aa7a253986af37b

Contents?: true

Size: 738 Bytes

Versions: 13

Compression:

Stored size: 738 Bytes

Contents

#!/usr/bin/env ruby

require 'benchmark'

n = 2000000
line = 's tupBel1.scaffold_3803.1-85889    33686 61 +    85889 ttcaggaagggggcccaaaacgcttgagtggtcagctctta-ttttgcgtttactggatggg'

Benchmark.bmbm do |x|
  x.report("basic String#split") do
    n.times do
      parts = line.split
    end
  end
  x.report("regex split") do
    n.times do
      parts = line.split(/\s+/)
    end
  end
  x.report("regex fields") do
    n.times do
      if m = /^s\s+(\S+)\s+(\d+)\s+(\d+)\s+([+-])\s+(\d+)\s+(\S+)/.match(line)
        parts = m.captures
      end
    end
  end
  x.report("regex fields") do
    n.times do
      if m = /^s\s+(\S+)\s+(\d+)\s+(\d+)\s+([+-])\s+(\d+)\s+(\S+)/.match(line)
        parts = m.captures
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bio-maf-1.0.1-java benchmarks/split_bench
bio-maf-1.0.1 benchmarks/split_bench
bio-maf-1.0.0-java benchmarks/split_bench
bio-maf-1.0.0 benchmarks/split_bench
bio-maf-0.3.2-java benchmarks/split_bench
bio-maf-0.3.2 benchmarks/split_bench
bio-maf-0.3.1 benchmarks/split_bench
bio-maf-0.3.0-java benchmarks/split_bench
bio-maf-0.3.0 benchmarks/split_bench
bio-maf-0.2.0-java benchmarks/split_bench
bio-maf-0.2.0 benchmarks/split_bench
bio-maf-0.1.0 benchmarks/split_bench
bio-maf-0.1.0-java benchmarks/split_bench