Class: ActiveSupport::Testing::Performance::Metrics::Base

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper
Defined in:
activesupport/lib/active_support/testing/performance.rb,
activesupport/lib/active_support/testing/performance/ruby.rb,
activesupport/lib/active_support/testing/performance/jruby.rb,
activesupport/lib/active_support/testing/performance/ruby/mri.rb,
activesupport/lib/active_support/testing/performance/rubinius.rb,
activesupport/lib/active_support/testing/performance/ruby/yarv.rb

Constant Summary

Constant Summary

Constants included from ActionView::Helpers::NumberHelper

ActionView::Helpers::NumberHelper::DECIMAL_UNITS, ActionView::Helpers::NumberHelper::DEFAULT_CURRENCY_VALUES, ActionView::Helpers::NumberHelper::STORAGE_UNITS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from ActionView::Helpers::NumberHelper

#number_to_currency, #number_to_human, #number_to_human_size, #number_to_percentage, #number_to_phone, #number_with_delimiter, #number_with_precision

Constructor Details

- (Base) initialize

A new instance of Base



253
254
255
# File 'activesupport/lib/active_support/testing/performance.rb', line 253

def initialize
  @total = 0
end

Instance Attribute Details

- (Object) loopback (readonly)

Returns the value of attribute loopback



67
68
69
# File 'activesupport/lib/active_support/testing/performance/rubinius.rb', line 67

def loopback
  @loopback
end

- (Object) total (readonly)

Returns the value of attribute total



251
252
253
# File 'activesupport/lib/active_support/testing/performance.rb', line 251

def total
  @total
end

Instance Method Details

- (Object) benchmark



261
262
263
264
265
266
267
# File 'activesupport/lib/active_support/testing/performance.rb', line 261

def benchmark            
  with_gc_stats do
    before = measure
    yield
    @total += (measure - before)
  end
end

- (Object) measure_mode



77
78
79
# File 'activesupport/lib/active_support/testing/performance/ruby.rb', line 77

def measure_mode
  self.class::Mode
end

- (Object) name



257
258
259
# File 'activesupport/lib/active_support/testing/performance.rb', line 257

def name
  @name ||= self.class.name.demodulize.underscore
end

- (Object) profile

overridden by each implementation



270
271
272
# File 'activesupport/lib/active_support/testing/performance.rb', line 270

def profile
  yield
end

- (Object) with_gc_stats

overridden by each implementation



274
275
276
277
278
279
280
# File 'activesupport/lib/active_support/testing/performance.rb', line 274

def with_gc_stats
  GC::Profiler.enable
  GC.start
  yield
ensure
  GC::Profiler.disable
end