Sha256: a70c89ae1816608f1e4cd6353e06610d76a43e33ffc425c5085154706fa780c0

Contents?: true

Size: 1.06 KB

Versions: 12

Compression:

Stored size: 1.06 KB

Contents

describe "Fortitude needs-building performance", :type => :system do
  CLASS_COUNT = 2_000
  NEEDS_NAMES = %w{foo bar baz quux marph}

  it "should build needs quickly" do
    skip "nope"

    widget_classes = [ ]

    puts "creating #{CLASS_COUNT} widget classes..."
    CLASS_COUNT.times do |i|
      klass = widget_class do
        def content
          "widget_class!"
        end
      end

      needs_count = rand(NEEDS_NAMES.length + 1)
      needs_count.times do |i|
        klass.send(:needs, NEEDS_NAMES[i] => "the_#{NEEDS_NAMES[i]}")
      end

      widget_classes << klass
    end

    start_time = Time.now
    widget_classes.each { |wc| wc.new }
    end_time = Time.now

    puts "Took #{end_time - start_time} seconds to instantiate all #{widget_classes.length} widget classes the first time."
    puts "total_time_spent: #{$total_time_spent}"

    start_time = Time.now
    widget_classes.each { |wc| wc.new }
    end_time = Time.now

    puts "Took #{end_time - start_time} seconds to instantiate all #{widget_classes.length} widget classes the second time."
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fortitude-0.9.6-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.6 spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.5-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.5 spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.4-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.4 spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.3-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.3 spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.2-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.2 spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.1-java spec/system/needs_building_performance_system_spec.rb
fortitude-0.9.1 spec/system/needs_building_performance_system_spec.rb