Sha256: 89f2d5c4147396825a4ec02bcbf84ee4bc4afd695a84855b6bdf8f420dd71db0

Contents?: true

Size: 1.47 KB

Versions: 15

Compression:

Stored size: 1.47 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 ActiveRecordTest < Performance::TestCase
  def setup
    require 'new_relic/agent/instrumentation/active_record_helper'

    ActiveRecordTest.const_set(:ActiveRecordHelper, NewRelic::Agent::Instrumentation::ActiveRecordHelper) unless defined?(ActiveRecordHelper)

    if ActiveRecordHelper.respond_to?(:metrics_for)
      @run = ActiveRecordHelper.method(:metrics_for)
    else
      # Mimics what was buried in the instrumentation that we replaced with
      # calls to metrics_for in the new instrumentation. Can run against SHA
      # 399d8ed for baselining (3.10 tags won't work since the perf testing
      # changed on dev post 3.10)
      @run = proc do |name, sql, adapter, *_|
        metric = ActiveRecordHelper.metric_for_name(name) ||
                 ActiveRecordHelper.metric_for_sql(sql)
        remote_service_metric = ActiveRecordHelper.remote_service_metric("host", adapter)

        metrics = [metric, remote_service_metric].compact
        metrics += ActiveRecordHelper.rollup_metrics_for(metric)
      end
    end
  end

  NAME    = "Model Load"
  SQL     = "SELECT * FROM star"
  ADAPTER = "mysql2"

  def test_helper_by_name
    measure do
      @run.call(NAME, SQL, ADAPTER)
    end
  end

  UNKNOWN_NAME = "Blah"

  def test_helper_by_sql
    measure do
      @run.call(UNKNOWN_NAME, SQL, ADAPTER)
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
newrelic_rpm-3.18.1.330 test/performance/suites/active_record.rb
newrelic_rpm-3.18.0.329 test/performance/suites/active_record.rb
newrelic_rpm-3.17.2.327 test/performance/suites/active_record.rb
newrelic_rpm-3.17.1.326 test/performance/suites/active_record.rb
newrelic_rpm-3.17.0.325 test/performance/suites/active_record.rb
newrelic_rpm-3.16.3.323 test/performance/suites/active_record.rb
newrelic_rpm-3.16.2.321 test/performance/suites/active_record.rb
newrelic_rpm-3.16.1.320 test/performance/suites/active_record.rb
newrelic_rpm-3.16.0.318 test/performance/suites/active_record.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/performance/suites/active_record.rb
newrelic_rpm-3.15.2.317 test/performance/suites/active_record.rb
newrelic_rpm-3.15.1.316 test/performance/suites/active_record.rb
newrelic_rpm-3.15.0.314 test/performance/suites/active_record.rb
newrelic_rpm-3.14.3.313 test/performance/suites/active_record.rb
newrelic_rpm-3.14.2.312 test/performance/suites/active_record.rb