Sha256: 5cb873e1c70255dfaba25ab9cd47785ff7192eec625f40bae56e0bb69eec3fe2

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require 'benchmark'

# member?

$n = 50000

def range_nan
  $n.times { ('a'..'k').member?('f') }
  $n.times { ('a'..'k').member?('r') }
end

def range_small
  $n.times { (0..6).member?(3) }
  $n.times { (0..6).member?(7) }
end

def range_med
  $n.times { (0..1000).member?(500) }
  $n.times { (0..1000).member?(1001) }
end

# index

$a = [ 'x' ] * 100
$m = 500000

def range_index
  i = 1
  $m.times { $a[1..i]; i += 1 }
end

def length_index
  i = 1
  $m.times { $a[1,i]; i += 1 }
end

### --- bench ---

puts "\nINDEXING"
Benchmark.bm(15) do |b|
  b.report("range_index:") { range_index }
  b.report("length_index:") { length_index }
end

puts "\n\nNew vs. Old\n"

puts "\nCURRENT"
Benchmark.bm(15) do |b|
  b.report("range_nan:") { range_nan }
  b.report("range_samll:") { range_small }
  b.report("range_med:") { range_med }
end

puts "\nNEW"
require 'trix-dev/range/range'
Benchmark.bm(15) do |b|
  b.report("range_nan:") { range_nan }
  b.report("range_samll:") { range_small }
  b.report("range_med:") { range_med }
end

puts

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
facets-2.9.2 work/bench/general/bench_range.rb
carats-0.3.0 bench/b_range.rb
facets-0.7.1 bench/b_range.rb
facets-0.7.0 bench/b_range.rb
facets-0.7.2 bench/b_range.rb
facets-0.9.0 bench/b_range.rb
facets-1.0.3 packages/more/bench/b_range.rb
facets-2.4.0 demo/bench/general/bench_range.rb
facets-2.3.0 demo/bench/general/bench_range.rb
facets-2.4.1 demo/bench/general/bench_range.rb
facets-2.4.3 demo/bench/general/bench_range.rb
facets-2.4.2 demo/bench/general/bench_range.rb
facets-2.4.4 demo/bench/general/bench_range.rb
facets-2.4.5 demo/bench/general/bench_range.rb
mega-0.3.1 bench/b_range.rb