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