Sha256: ad68f13491c28863ba6a5666d80016fe793b3c8e9b714cb16b8ab3aeb89cb7c4

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path(File.join(__dir__,'..','lib')))

require 'chars'
require 'benchmark'

CHARSET = Chars::ALPHA_NUMERIC
STRING  = File.binread('/usr/bin/openssl')

Benchmark.bm(41) do |b|
  b.report('Chars::CharSet#each_substring_with_index') do
    CHARSET.each_substring_with_index(STRING) { |string,index| }
  end

  b.report('Chars::CharSet#each_substring') do
    CHARSET.each_substring(STRING) { |string| }
  end

  (5..20).step(5) do |n|
    b.report("Chars::CharSet#each_substring (length=#{n})") do
      CHARSET.strings_in(STRING, :length => n) { |offset,string| }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chars-0.3.3 benchmarks/substrings.rb
chars-0.3.2 benchmarks/substrings.rb
chars-0.3.1 benchmarks/substrings.rb
chars-0.3.0 benchmarks/substrings.rb