Class: SimpleProfiler::Event

Inherits:
Struct
  • Object
show all
Defined in:
lib/simple_profiler/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def args
  @args
end

#finalized_atObject

Returns the value of attribute finalized_at

Returns:

  • (Object)

    the current value of finalized_at



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def finalized_at
  @finalized_at
end

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def klass
  @klass
end

#memory_at_beginningObject

Returns the value of attribute memory_at_beginning

Returns:

  • (Object)

    the current value of memory_at_beginning



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def memory_at_beginning
  @memory_at_beginning
end

#memory_at_endObject

Returns the value of attribute memory_at_end

Returns:

  • (Object)

    the current value of memory_at_end



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def memory_at_end
  @memory_at_end
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def method
  @method
end

#started_atObject

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def started_at
  @started_at
end

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



2
3
4
# File 'lib/simple_profiler/event.rb', line 2

def target
  @target
end

Instance Method Details

#to_sObject



12
13
14
15
# File 'lib/simple_profiler/event.rb', line 12

def to_s
  separator = target == :class ? '.' : '#'
  "#{klass}#{separator}#{method} -> #{total_time.round(4)} sec. - #{used_memory}MB - (Total Memory: #{memory_at_end}MB)"
end

#total_timeObject



4
5
6
# File 'lib/simple_profiler/event.rb', line 4

def total_time
  finalized_at - started_at
end

#used_memoryObject



8
9
10
# File 'lib/simple_profiler/event.rb', line 8

def used_memory
  memory_at_end - memory_at_beginning
end