Sha256: d22409e87b96615145bcbfd980d5f1c3d04c1b9cae478d0016e1ae0e9fc8c4b7

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

class ConfigPerfTests < Performance::TestCase
  def setup
    @config = NewRelic::Agent::Configuration::Manager.new
    @config.add_config_for_testing(:my_value => "boo")
  end

  def test_raw_access
    iterations.times do
      v = @config[:my_value]
    end
  end

  def test_defaulting_access
    iterations.times do
      v = @config[:log_level]
    end
  end

  def test_missing_key
    iterations.times do
      v = @config[:nope]
    end
  end

  def test_blowing_cache
    iterations.times do
      @config.reset_cache
      v = @config[:my_value]
    end
  end

  def test_deep_config_stack_raw_access(timer)
    with_deep_config_stack

    timer.measure do
      iterations.times do
        v = @config[:my_value]
      end
    end
  end

  def test_deep_config_stack_defaulting_access(timer)
    with_deep_config_stack

    timer.measure do
      iterations.times do
        v = @config[:log_level]
      end
    end
  end

  def test_deep_config_stack_across_all_levels(timer)
    keys = with_deep_config_stack

    timer.measure do
      iterations.times do
        keys.each do |key|
          v = @config[key]
        end
      end
    end
  end


  def with_deep_config_stack
    # NOTE: As we have changed the way configs work, this example no longer
    #       simulates production code. It would be impossible to have more than
    #       5 levels on the config stack now.
    keys = (0..100).map {|i| "my_value_#{i}".to_sym}
    keys.each do |key|
      @config.add_config_for_testing(key => key)
    end
    keys
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
newrelic_rpm-3.10.0.279 test/performance/suites/config.rb
newrelic_rpm-3.9.9.275 test/performance/suites/config.rb
newrelic_rpm-3.9.8.273 test/performance/suites/config.rb
newrelic_rpm-3.9.7.266 test/performance/suites/config.rb
newrelic_rpm-3.9.6.257 test/performance/suites/config.rb
newrelic_rpm-3.9.5.251 test/performance/suites/config.rb
newrelic_rpm-3.9.4.245 test/performance/suites/config.rb
newrelic_rpm-3.9.3.241 test/performance/suites/config.rb
newrelic_rpm-3.9.2.239 test/performance/suites/config.rb
newrelic_rpm-3.9.1.236 test/performance/suites/config.rb
newrelic_rpm-3.9.0.229 test/performance/suites/config.rb