Sha256: 72612f8074518736886f19aa1f5a6c53ffb6ac8f782f6cb2c30f5b76ec85bd37

Contents?: true

Size: 725 Bytes

Versions: 14

Compression:

Stored size: 725 Bytes

Contents

require 'cartesian'
require 'benchmark'

MULTIPLIER = 3
letras = ("a"*MULTIPLIER.."z"*MULTIPLIER).to_a
numeros = (0..10**1).to_a

Benchmark.bmbm do |x|
  letras_numeros = nil
  x.report("product") { letras_numeros = Cartesian.product(letras, numeros) }
  x.report("product 2") { for x,y in letras_numeros; end }

  x.report(".x") { letras_numeros = letras.x(numeros) }
  x.report(".x 2") { for x,y in letras_numeros; end }
end

#~ x.report("productZip") { Cartesian.productZip(letras, numeros) }

  #~ def Cartesian.productZip(first, second)
    #~ result = []
    #~ first.each do |a|
      #~ aaa = Array.new(second.size) { a }
      #~ result += aaa.zip(second)
    #~ end
    #~ result
  #~ end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
cartesian-0.6.7 test/benchmark.rb
cartesian-0.6.6 test/benchmark.rb
cartesian-0.6.5 test/benchmark.rb
cartesian-0.6.4 test/benchmark.rb
cartesian-0.6.3 test/benchmark.rb
cartesian-0.6.2 test/benchmark.rb
cartesian-0.6.0 test/benchmark.rb
cartesian-0.5.3 test/benchmark.rb
cartesian-0.5.2 test/benchmark.rb
cartesian-0.5.0 test/benchmark.rb
Cartesian-0.2.1 tests/benchmark.rb
Cartesian-0.3.0 tests/benchmark.rb
Cartesian-0.2.3 tests/benchmark.rb
Cartesian-0.4.1 tests/benchmark.rb