class EasyProfiler::Configuration

Attributes

colorize_logging[R]
count_ar_instances[R]

Value indicating whether profiler should log an approximate number of instantiated ActiveRecord objects.

count_memory_usage[R]

Value indicating whether profiler should log an approximate amount of memory used.

enable_profiling[R]

Value indicating whether profiling is globally enabled.

live_logging[R]

Value indicating whether profiler should flush logs on every checkpoint.

logger[W]

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.

print_limit[R]

Minimum time period which should be reached to dump profile to the log.

Public Class Methods

new() click to toggle source
# 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
parse(config) click to toggle source
# 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

colorize_logging=(value) click to toggle source
# File lib/easy_prof/configuration.rb, line 66
def colorize_logging=(value)
  @colorize_logging = !!value
end
count_ar_instances=(value) click to toggle source

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
count_memory_usage=(value) click to toggle source

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
disable_gc?() click to toggle source
# File lib/easy_prof/configuration.rb, line 122
def disable_gc?
  count_ar_instances or count_memory_usage
end
enable_profiling=(value) click to toggle source

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
enabled?() click to toggle source
# File lib/easy_prof/configuration.rb, line 126
def enabled?
  enable_profiling
end
live_logging=(value) click to toggle source

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
logger() click to toggle source

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
merge(options = {}) click to toggle source
# 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
print_limit=(value) click to toggle source

Sets a minimum time period which should be reached to dump profile to the log.