Sha256: 9fc07935f6701f85bf3c30467400b4cbb51989ae9773d1e2e75872cfe7c7d9ee

Contents?: true

Size: 1.58 KB

Versions: 11

Compression:

Stored size: 1.58 KB

Contents

require 'benchmark'
require File.join(File.dirname(__FILE__),'../lib/marvin')

LINES = [
  ":irc.darth.vpn.spork.in 366 testbot #testing :End of NAMES list",
  ":Helsinki.FI.EU.Undernet.org PONG Helsinki.FI.EU.Undernet.org :Helsinki.FI.EU.Undernet.org",
  ":testnick USER guest tolmoon tolsun :Ronnie Reagan",
  "LIST #twilight_zone,#42",
  ":WiZ LINKS *.bu.edu *.edu",
  ":Angel PRIVMSG Wiz :Hello are you receiving this message ?",
  ":RelayBot!n=MarvinBo@203.161.81.201.static.amnet.net.au JOIN :#relayrelay",
  ":SuttoL!n=SuttoL@li6-47.members.linode.com PRIVMSG #relayrelay :testing...",
  ":wolfe.freenode.net 004 MarvinBot3000 wolfe.freenode.net hyperion-1.0.2b aAbBcCdDeEfFGhHiIjkKlLmMnNopPQrRsStTuUvVwWxXyYzZ01234569*@ bcdefFhiIklmnoPqstv"
]
PARSERS = [Marvin::Parsers::RagelParser, Marvin::Parsers::SimpleParser, Marvin::Parsers::RegexpParser]

LINES.each do |line|
  
  puts "Processing: #{line}"
  puts ""
  cmd = []
  
  PARSERS.each do |p|
    parser = p.new(line)
    ev    = parser.to_event
    puts "Parser:  #{p.name}"
    if ev.nil?
      puts "Unknown Event"
    else
      puts ev.to_hash.inspect
    end
    puts ""
  end
  puts ""
  
end

puts ""
puts ""
puts "==============="
puts "| SPEED TESTS |"
puts "==============="
puts ""

width = PARSERS.map { |p| p.name.length }.max + 2

ITERATIONS = 1000

Benchmark.bm(width) do |b|
  PARSERS.each do |parser|
    b.report("#{parser.name}: ") do
      LINES.each do |l|
        ITERATIONS.times do
          e = parser.new(l).to_event
          unless e.nil?
            e.to_hash # Get a hash
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
Sutto-marvin-0.2.0 test/parser_comparison.rb
Sutto-marvin-0.2.1 test/parser_comparison.rb
Sutto-marvin-0.2.2 test/parser_comparison.rb
Sutto-marvin-0.2.3 test/parser_comparison.rb
Sutto-marvin-0.2.4 test/parser_comparison.rb
Sutto-marvin-0.3.0 test/parser_comparison.rb
Sutto-marvin-0.3.2 test/parser_comparison.rb
Sutto-marvin-0.3.3 test/parser_comparison.rb
Sutto-marvin-0.3.4 test/parser_comparison.rb
Sutto-marvin-0.4.0 test/parser_comparison.rb
jeffrafter-marvin-0.1.20081120 test/parser_comparison.rb