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

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/testing/performance.rb

Direct Known Subclasses

GcRuns, GcTime, Memory, Objects, Time

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



230
231
232
# File 'lib/active_support/testing/performance.rb', line 230

def initialize
  @total = 0
end

Instance Attribute Details

#totalObject (readonly)

Returns the value of attribute total.



228
229
230
# File 'lib/active_support/testing/performance.rb', line 228

def total
  @total
end

Instance Method Details

#benchmarkObject



246
247
248
249
250
251
252
# File 'lib/active_support/testing/performance.rb', line 246

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

#measureObject



242
243
244
# File 'lib/active_support/testing/performance.rb', line 242

def measure
  0
end

#measure_modeObject



238
239
240
# File 'lib/active_support/testing/performance.rb', line 238

def measure_mode
  self.class::Mode
end

#nameObject



234
235
236
# File 'lib/active_support/testing/performance.rb', line 234

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

#profileObject



254
255
256
257
258
259
# File 'lib/active_support/testing/performance.rb', line 254

def profile
  RubyProf.resume
  yield
ensure
  RubyProf.pause
end