Module: ActiveSupport::Testing::Performance

### Home Classes Methods

### In Files

- lib/active_support/testing/performance.rb

### Namespace

- MODULE ActiveSupport::Testing::Performance::Metrics
- CLASS ActiveSupport::Testing::Performance::Benchmarker
- CLASS ActiveSupport::Testing::Performance::Performer
- CLASS ActiveSupport::Testing::Performance::Profiler

### Methods

- ::included
- #full_test_name
- #run
- #run_profile
- #run_test
- #run_warmup

### Class/Module Index

Quicksearch

- ActiveSupport
- ActiveSupport::Autoload
- ActiveSupport::BacktraceCleaner
- ActiveSupport::Base64
- ActiveSupport::BasicObject
- ActiveSupport::Benchmarkable
- ActiveSupport::BufferedLogger
- ActiveSupport::BufferedLogger::Severity
- ActiveSupport::Cache
- ActiveSupport::Cache::CompressedMemCacheStore
- ActiveSupport::Cache::Entry
- ActiveSupport::Cache::FileStore
- ActiveSupport::Cache::MemCacheStore
- ActiveSupport::Cache::MemoryStore
- ActiveSupport::Cache::Store
- ActiveSupport::Cache::Strategy
- ActiveSupport::Cache::Strategy::LocalCache
- ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- ActiveSupport::Cache::SynchronizedMemoryStore
- ActiveSupport::Callbacks
- ActiveSupport::Callbacks::Callback
- ActiveSupport::Callbacks::CallbackChain
- ActiveSupport::Callbacks::ClassMethods
- ActiveSupport::Concern
- ActiveSupport::Configurable
- ActiveSupport::Configurable::ClassMethods
- ActiveSupport::Dependencies
- ActiveSupport::Dependencies::Reference
- ActiveSupport::Dependencies::WatchStack
- ActiveSupport::Deprecation
- ActiveSupport::DescendantsTracker
- ActiveSupport::Duration
- ActiveSupport::FileUpdateChecker
- ActiveSupport::Gzip
- ActiveSupport::Gzip::Stream
- ActiveSupport::HashWithIndifferentAccess
- ActiveSupport::HashWithIndifferentAccess
- ActiveSupport::Inflector
- ActiveSupport::Inflector::Inflections
- ActiveSupport::InheritableOptions
- ActiveSupport::JSON
- ActiveSupport::JSON::Backends
- ActiveSupport::JSON::Backends::JSONGem
- ActiveSupport::JSON::Backends::Yajl
- ActiveSupport::JSON::Backends::Yaml
- ActiveSupport::JSON::Encoding
- ActiveSupport::JSON::Encoding::CircularReferenceError
- ActiveSupport::JSON::Encoding::Encoder
- ActiveSupport::JSON::Variable
- ActiveSupport::LogSubscriber
- ActiveSupport::LogSubscriber::TestHelper
- ActiveSupport::LogSubscriber::TestHelper::MockLogger
- ActiveSupport::Memoizable
- ActiveSupport::Memoizable::InstanceMethods
- ActiveSupport::MessageEncryptor
- ActiveSupport::MessageEncryptor::InvalidMessage
- ActiveSupport::MessageVerifier
- ActiveSupport::MessageVerifier::InvalidSignature
- ActiveSupport::Multibyte
- ActiveSupport::Multibyte::Chars
- ActiveSupport::Multibyte::EncodingError
- ActiveSupport::Multibyte::Unicode
- ActiveSupport::Multibyte::Unicode::Codepoint
- ActiveSupport::Multibyte::Unicode::UnicodeDatabase
- ActiveSupport::Notifications
- ActiveSupport::Notifications::Event
- ActiveSupport::Notifications::Fanout
- ActiveSupport::Notifications::Instrumenter
- ActiveSupport::OrderedOptions
- ActiveSupport::Railtie
- ActiveSupport::Rescuable
- ActiveSupport::Rescuable::ClassMethods
- ActiveSupport::SafeBuffer
- ActiveSupport::SecureRandom
- ActiveSupport::StringInquirer
- ActiveSupport::TestCase
- ActiveSupport::Testing
- ActiveSupport::Testing::Assertions
- ActiveSupport::Testing::Declarative
- ActiveSupport::Testing::Isolation
- ActiveSupport::Testing::Isolation::Forking
- ActiveSupport::Testing::Isolation::MiniTest
- ActiveSupport::Testing::Isolation::Subprocess
- ActiveSupport::Testing::Isolation::TestUnit
- ActiveSupport::Testing::Pending
- ActiveSupport::Testing::Performance
- ActiveSupport::Testing::Performance::Benchmarker
- ActiveSupport::Testing::Performance::Metrics
- ActiveSupport::Testing::Performance::Metrics::Base
- ActiveSupport::Testing::Performance::Metrics::CpuTime
- ActiveSupport::Testing::Performance::Metrics::GcRuns
- ActiveSupport::Testing::Performance::Metrics::GcTime
- ActiveSupport::Testing::Performance::Metrics::Memory
- ActiveSupport::Testing::Performance::Metrics::Objects
- ActiveSupport::Testing::Performance::Metrics::ProcessTime
- ActiveSupport::Testing::Performance::Metrics::Time
- ActiveSupport::Testing::Performance::Metrics::WallTime
- ActiveSupport::Testing::Performance::Performer
- ActiveSupport::Testing::Performance::Profiler
- ActiveSupport::Testing::ProxyTestResult
- ActiveSupport::Testing::RemoteError
- ActiveSupport::Testing::SetupAndTeardown
- ActiveSupport::Testing::SetupAndTeardown::ClassMethods
- ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
- ActiveSupport::Testing::SetupAndTeardown::ForMiniTest
- ActiveSupport::TimeWithZone
- ActiveSupport::TimeZone
- ActiveSupport::XmlMini
- ActiveSupport::XmlMini_LibXMLSAX
- ActiveSupport::XmlMini_LibXMLSAX::HashBuilder
- ActiveSupport::XmlMini_NokogiriSAX
- ActiveSupport::XmlMini_NokogiriSAX::HashBuilder
- Test
- Test::Unit
- Test::Unit::Collector
- Test::Unit::Collector::ObjectSpace
- Object
- Object::HashWithIndifferentAccess
- Object::MissingSourceFile
- ERB
- ERB::Util
- I18n
- I18n::Railtie
- LoadError
- LoadError
- Logger
- Logger::SimpleFormatter
- Array
- Benchmark
- BigDecimal
- Class
- Date
- DateTime
- Enumerable
- FalseClass
- File
- Fixnum
- Float
- Hash
- Integer
- Kernel
- Module
- NameError
- NilClass
- Numeric
- Process
- Range
- Regexp
- String
- Symbol
- Time
- TrueClass

No matching classes.

# ActiveSupport::Testing::Performance

### Constants

DEFAULTS

### Public Class Methods

included(base) click to toggle source

    # File lib/active_support/testing/performance.rb, line 27
    def self.included(base)
      base.superclass_delegating_accessor :profile_options
      base.profile_options = DEFAULTS
    end

### Public Instance Methods

full_test_name() click to toggle source

    # File lib/active_support/testing/performance.rb, line 32
    def full_test_name
      "#{self.class.name}##{method_name}"
    end

run(result) click to toggle source

    # File lib/active_support/testing/performance.rb, line 36
    def run(result)
      return if method_name =~ /^default_test$/

      yield(self.class::STARTED, name)
      @_result = result

      run_warmup
      if profile_options && metrics = profile_options[:metrics]
        metrics.each do |metric_name|
          if klass = Metrics[metric_name.to_sym]
            run_profile(klass.new)
            result.add_run
          end
        end
      end

      yield(self.class::FINISHED, name)
    end

run_test(metric, mode) click to toggle source

    # File lib/active_support/testing/performance.rb, line 55
    def run_test(metric, mode)
      run_callbacks :setup
      setup
      metric.send(mode) { __send__ @method_name }
    rescue ::Test::Unit::AssertionFailedError => e
      add_failure(e.message, e.backtrace)
    rescue StandardError, ScriptError => e
      add_error(e)
    ensure
      begin
        teardown
        run_callbacks :teardown, :enumerator => :reverse_each
      rescue ::Test::Unit::AssertionFailedError => e
        add_failure(e.message, e.backtrace)
      rescue StandardError, ScriptError => e
        add_error(e)
      end
    end

### Protected Instance Methods

run_profile(metric) click to toggle source

    # File lib/active_support/testing/performance.rb, line 85
    def run_profile(metric)
      klass = profile_options[:benchmark] ? Benchmarker : Profiler
      performer = klass.new(self, metric)

      performer.run
      puts performer.report
      performer.record
    end

run_warmup() click to toggle source

    # File lib/active_support/testing/performance.rb, line 75
    def run_warmup
      GC.start

      time = Metrics::Time.new
      run_test(time, :benchmark)
      puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]

      GC.start
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.