Sha256: 66cad0fbac88e6edbfa89d6e760c5b71e47de97d2f15bf139116bfd5a389a8d1

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Indexing::Bundle::Memory do

  before(:each) do
    @index            = Index::Memory.new :some_index, source: []
    @category         = Category.new :some_category, @index
    
    @partial_strategy = Generators::Partial::Substring.new :from => 1
    @exact            = described_class.new :some_name, @category, nil, @partial_strategy, nil
  end

  def generate_random_keys amount
    alphabet = ('a'..'z').to_a
    (1..amount).to_a.collect! do |n|
      Array.new(20).collect! { alphabet[rand(26)] }.join.to_sym
    end
  end
  def generate_random_ids amount
    (1..amount).to_a.collect! do |_|
      Array.new(rand(100)+5).collect! do |_|
        rand(5_000_000)
      end
    end
  end

  describe 'speed' do
    context 'medium arrays' do
      before(:each) do
        random_keys     = generate_random_keys 300
        random_ids      = generate_random_ids  300
        @exact.inverted = Hash[random_keys.zip(random_ids)]
      end
      it 'should be fast' do
        performance_of do
          @exact.generate_partial
        end.should < 0.1
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 spec/lib/indexing/bundle/memory_partial_generation_speed_spec.rb