Sha256: e7a29aaf1745bc1ad724f901850cb302a76be91e3e92e47d1172438eba95a41e

Contents?: true

Size: 395 Bytes

Versions: 13

Compression:

Stored size: 395 Bytes

Contents

require "strscan"
require_relative "../lib/zscan"
require "benchmark"

s = "word\n"
s *= 3_000_000

puts "StringScanner:"
sc = StringScanner.new s
puts Benchmark.measure{
  until sc.eos?
    sc.scan(/\w+/) and (sc.pos += 1)
  end
}

puts
puts "ZScan should be nearly as fast as StringScanner"
zc = ZScan.new s
puts Benchmark.measure{
  until zc.eos?
    zc.scan(/\w+/) and zc.advance(1)
  end
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
zscan-2.0.9 benchmark/vs-strscan.rb
zscan-2.0.8 benchmark/vs-strscan.rb
zscan-2.0.7 benchmark/vs-strscan.rb
zscan-2.0.6 benchmark/vs-strscan.rb
zscan-2.0.5 benchmark/vs-strscan.rb
zscan-2.0.4 benchmark/vs-strscan.rb
zscan-2.0.3 benchmark/vs-strscan.rb
zscan-2.0.2 benchmark/vs-strscan.rb
zscan-2.0.1 benchmark/vs-strscan.rb
zscan-2.0 benchmark/vs-strscan.rb
zscan-1.3 benchmark/vs-strscan.rb
zscan-1.2 benchmark/vs-strscan.rb
zscan-1.1 benchmark/vs-strscan.rb