Module: ActiveProfiling::GCStatistics
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveProfiling
- Defined in:
- lib/active-profiling/gc_statistics.rb
Instance Method Summary collapse
-
#gc_statistics(*args) ⇒ Object
Profiles a block, capturing information on the garbage collector.
Instance Method Details
#gc_statistics(*args) ⇒ Object
Profiles a block, capturing information on the garbage collector. The return value is an Array containing the result of the yielded block and a String with a report on the profiling results.
Options:
-
:disable_gc
- disables garbage collection for the duration of the block and then renables it immediately afterwards. This allows you to control when GC is run and see the results. -
:title
- a title to use for logging.
More options for this method can be found in the default settings, located in ActiveProfiling::Railtie::DEFAULT_GC_STATISTICS_OPTIONS.
This method only works with versions of Ruby that implement GC::Profiler or that have been patched to implement some additional garbage collection statistics. In older versions, such as version 1.8.7, you can either use Ruby Enterprise Edition or patch your build with the GC statistics patch found here:
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/active-profiling/gc_statistics.rb', line 88 def gc_statistics(*args) = Rails.application.config.active_profiling.gc_statistics.merge(args.) result, gc_report = gc_statistics_report() do yield end ActiveSupport::Notifications.instrument('gc_statistics.active_profiling', { :report => gc_report, :title => [:title] || args.first }) result end |