Class: EasyProfiler::ProfileInstanceBase

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_prof/profile_instance_base.rb

Overview

Base class for profilers.

Direct Known Subclasses

NoProfileInstance, ProfileInstance

Constant Summary collapse

@@row_even =
true

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config = nil) ⇒ ProfileInstanceBase

Initializes a new instance of ProfileInstanceBase class.

Parameters:

  • name – session name.

  • options – a Hash of options (see EasyProfiler::Profile.start for details).



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/easy_prof/profile_instance_base.rb', line 13

def initialize(name, config = nil)
  @name = name
  @config = Configuration.parse(config)

  @start = @progress = Time.now.to_f

  # Initial number of ActiveRecord::Base objects
  if @config.count_ar_instances
    @start_ar_instances = @current_ar_instances = active_record_instances_count
  end

  # Initial amount of memory used
  if @config.count_memory_usage
    @start_memory_usage = @current_memory_usage = process_memory_usage
  end

  # A buffer where all log messeges will be stored till the
  # end of the profiling block. We need this because not every
  # profiling log will be printed (see EasyProf::Configuration.print_limit).
  @buffer = []
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



4
5
6
# File 'lib/easy_prof/profile_instance_base.rb', line 4

def buffer
  @buffer
end

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/easy_prof/profile_instance_base.rb', line 4

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/easy_prof/profile_instance_base.rb', line 4

def name
  @name
end

Instance Method Details

#debug(message) ⇒ Object

Sets a profiling checkpoint without execution time printing.

Parameters:

  • message – a message to associate with a check point.



48
49
# File 'lib/easy_prof/profile_instance_base.rb', line 48

def debug(message)
end

#dump_resultsObject

Dumps results to the log.



64
65
# File 'lib/easy_prof/profile_instance_base.rb', line 64

def dump_results
end

#end_groupObject



60
61
# File 'lib/easy_prof/profile_instance_base.rb', line 60

def end_group
end

#group(name, options = {}, &block) ⇒ Object

Start a group with a specified name.

Parameters:

  • name – a name of the group.



56
57
58
# File 'lib/easy_prof/profile_instance_base.rb', line 56

def group(name, options = {}, &block)
  self
end

#progress(message) ⇒ Object

Sets a profiling checkpoint (block execution time will be printed).

Parameters:

  • message – a message to associate with a check point.



40
41
# File 'lib/easy_prof/profile_instance_base.rb', line 40

def progress(message)
end