Sha256: c58c0409b6e3c10322851828c843c6a4f2eddb1ffbdcc672703b61a08da2b509

Contents?: true

Size: 1.22 KB

Versions: 36

Compression:

Stored size: 1.22 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "Speccing Ruby for speed" do
  describe "various versions for allocation id concatenating" do
    before(:each) do
      @allocs = [:hello, :speed, :test]
      @ids = {
        :hello => (1..100_000).to_a,
        :speed => (1..5_000).to_a,
        :test => (1..1_000).to_a
      }
    end
    describe "+" do
      it "should be fast" do
        performance_of do
          @allocs.inject([]) do |total, alloc|
            total + @ids[alloc]
          end
        end.should < 0.0025
      end
    end
    describe "map and flatten!(1)" do
      it "should be fast" do
        performance_of do
          @allocs.map { |alloc| @ids[alloc] }.flatten!(1)
        end.should < 0.02
      end
    end
    describe "<< and flatten!(1)" do
      it "should be fast" do
        performance_of do
          @allocs.inject([]) do |total, alloc|
            total << @ids[alloc]
          end.flatten!(1)
        end.should < 0.02
      end
    end
    describe "<< and flatten!" do
      it "should be fast" do
        performance_of do
          @allocs.inject([]) do |total, alloc|
            total << @ids[alloc]
          end.flatten!
        end.should < 0.02
      end
    end
  end
  
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
picky-1.3.0 spec/specific/speed_spec.rb
picky-1.2.4 spec/specific/speed_spec.rb
picky-1.2.3 spec/specific/speed_spec.rb
picky-1.2.2 spec/specific/speed_spec.rb
picky-1.2.1 spec/specific/speed_spec.rb
picky-1.2.0 spec/specific/speed_spec.rb
picky-1.1.7 spec/specific/speed_spec.rb
picky-1.1.6 spec/specific/speed_spec.rb
picky-1.1.5 spec/specific/speed_spec.rb
picky-1.1.4 spec/specific/speed_spec.rb
picky-1.1.3 spec/specific/speed_spec.rb
picky-1.1.2 spec/specific/speed_spec.rb
picky-1.1.1 spec/specific/speed_spec.rb
picky-1.1.0 spec/specific/speed_spec.rb
picky-1.0.0 spec/specific/speed_spec.rb
picky-0.12.3 spec/specific/speed_spec.rb
picky-0.12.2 spec/specific/speed_spec.rb
picky-0.12.1 spec/specific/speed_spec.rb
picky-0.12.0 spec/specific/speed_spec.rb
picky-0.11.2 spec/specific/speed_spec.rb