| Class | ActiveSupport::Testing::Metrics::Base |
| In: |
vendor/rails/activesupport/lib/active_support/testing/performance.rb
|
| Parent: | Object |
| total | [R] |
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 230
230: def initialize
231: @total = 0
232: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 246
246: def benchmark
247: with_gc_stats do
248: before = measure
249: yield
250: @total += (measure - before)
251: end
252: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 242
242: def measure
243: 0
244: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 238
238: def measure_mode
239: self.class::Mode
240: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 234
234: def name
235: @name ||= self.class.name.demodulize.underscore
236: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 254
254: def profile
255: RubyProf.resume
256: yield
257: ensure
258: RubyProf.pause
259: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 270
270: def with_gc_stats
271: GC.start
272: GC.disable
273: GC::Profiler.enable
274: yield
275: ensure
276: GC::Profiler.disable
277: GC.enable
278: end
# File vendor/rails/activesupport/lib/active_support/testing/performance.rb, line 263
263: def with_gc_stats
264: GC.enable_stats
265: yield
266: ensure
267: GC.disable_stats
268: end