Sha256: 62a536536b4d2820a1c494eefccac371fd435d2e78c124774b08adf4b37ad508

Contents?: true

Size: 1.04 KB

Versions: 33

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'benchmark'
require 'flamegraph'

describe 'Benchmark making answer entities', benchmark: true do
  let(:definition) do
    pieces = []

    500.times do |i|
      pieces << <<-END
        question :v_#{i}, type: :radio, required: false do
          title "Choose"
          option :a1, value: 1, description: "Ja"
          option :a2, value: 2, description: "Nee"
        end
      END
    end

    pieces.join("\n\n")

  end

  let(:questionnaire) { inject_questionnaire("test", definition) }
  let!(:sample_count) { 1000 }

  it 'is quick for large questionnaires' do
    # initialize questionnaire outside profiler
    RubyProf.pause if RubyProf.running?
    questionnaire.questions
    expect(questionnaire.key).to eq('test')
    Quby::Answers::Entities::Answer.new(questionnaire_key: questionnaire.key).enhance_by_dsl
    RubyProf.resume if RubyProf.running?

    sample_count.times do
      Quby::Answers::Entities::Answer.new(questionnaire_key: questionnaire.key).enhance_by_dsl
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
quby-5.6.5 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.6.3 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.6.2 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.6.1 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.6.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.5.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.4.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.3.1 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.3.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.2.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.1.3 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.1.2 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.1.1 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.1.0 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.5 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.4 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.3 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.2 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.1 spec/benchmarks/answer_instantiation_speed_spec.rb
quby-5.0.0 spec/benchmarks/answer_instantiation_speed_spec.rb