class EasyProfiler::Configuration
Attributes
Value indicating whether profiler should log an approximate number of instantiated ActiveRecord objects.
Value indicating whether profiler should log an approximate amount of memory used.
Value indicating whether profiling is globally enabled.
Value indicating whether profiler should flush logs on every checkpoint.
Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed on to any profiler instance made.
Minimum time period which should be reached to dump profile to the log.
Public Class Methods
# File lib/easy_prof/configuration.rb, line 29 def initialize @enable_profiling = false @print_limit = 0.01 @count_ar_instances = false @count_memory_usage = false @logger = nil @colorize_logging = false @live_logging = false end
# File lib/easy_prof/configuration.rb, line 111 def self.parse(config) case config when Hash EasyProfiler.configuration.merge(config) when EasyProfiler::Configuration config else EasyProfiler.configuration end end
Public Instance Methods
# File lib/easy_prof/configuration.rb, line 66 def colorize_logging=(value) @colorize_logging = !!value end
Sets a value indicating whether profiler should log an approximate number of instantiated ActiveRecord objects.
# File lib/easy_prof/configuration.rb, line 52 def count_ar_instances=(value) @count_ar_instances = !!value end
Sets a value indicating whether profiler should log an approximate amount of memory used.
@param Boolean value
identifies whether memory profiling should be enabled.
# File lib/easy_prof/configuration.rb, line 62 def count_memory_usage=(value) @count_memory_usage = !!value end
# File lib/easy_prof/configuration.rb, line 122 def disable_gc? count_ar_instances or count_memory_usage end
Sets a value indicating whether profiling is globally enabled.
# File lib/easy_prof/configuration.rb, line 40 def enable_profiling=(value) @enable_profiling = !!value end
# File lib/easy_prof/configuration.rb, line 126 def enabled? enable_profiling end
Sets a value indicating whether profiler should flush logs on every checkpoint.
# File lib/easy_prof/configuration.rb, line 73 def live_logging=(value) @live_logging = !!value end
Gets a logger instance.
When profiler is started inside Rails application, creates a “log/profile.log” files where all profile logs will be places. In regular scripts dumps information directly to STDOUT. You can use EasyProfiler.configuration.logger
to set another logger.
# File lib/easy_prof/configuration.rb, line 86 def logger unless @logger @logger = if Object.const_defined?(:Rails) Logger.new(File.join(Rails.root, 'log', 'profile.log')) else Logger.new($stdout) end end @logger end
# File lib/easy_prof/configuration.rb, line 97 def merge(options = {}) config = self.dup config.enable_profiling = options[:enabled] if options.has_key?(:enabled) config.enable_profiling = options[:enable_profiling] if options.has_key?(:enable_profiling) config.print_limit = options[:limit] if options.has_key?(:limit) config.print_limit = options[:print_limit] if options.has_key?(:print_limit) config.count_ar_instances = options[:count_ar_instances] if options.has_key?(:count_ar_instances) config.count_memory_usage = options[:count_memory_usage] if options.has_key?(:count_memory_usage) config.logger = options[:logger] if options.has_key?(:logger) config.colorize_logging = options[:colorize_logging] if options.has_key?(:colorize_logging) config.live_logging = options[:live_logging] if options.has_key?(:live_logging) config end
Sets a minimum time period which should be reached to dump profile to the log.
# File lib/easy_prof/configuration.rb, line 46 def print_limit=(value) @print_limit = FalseClass === value ? false : value.to_f end