Class: SpeedGun::Source::Line
- Inherits:
-
Object
- Object
- SpeedGun::Source::Line
- Defined in:
- lib/speed_gun/source.rb
Instance Attribute Summary collapse
-
#allocations ⇒ Object
readonly
Returns the value of attribute allocations.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#wall ⇒ Object
readonly
Returns the value of attribute wall.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line, code, wall, cpu, calls, allocations) ⇒ Line
constructor
A new instance of Line.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(line, code, wall, cpu, calls, allocations) ⇒ Line
Returns a new instance of Line.
19 20 21 22 |
# File 'lib/speed_gun/source.rb', line 19 def initialize(line, code, wall, cpu, calls, allocations) @id = SecureRandom.uuid @line, @code, @wall, @cpu, @calls, @allocations = line, code, wall, cpu, calls, allocations end |
Instance Attribute Details
#allocations ⇒ Object (readonly)
Returns the value of attribute allocations.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def allocations @allocations end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def calls @calls end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def code @code end |
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def cpu @cpu end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def id @id end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def line @line end |
#wall ⇒ Object (readonly)
Returns the value of attribute wall.
9 10 11 |
# File 'lib/speed_gun/source.rb', line 9 def wall @wall end |
Class Method Details
.from_hash(hash, id = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/speed_gun/source.rb', line 11 def self.from_hash(hash, id = nil) keys = %w(line code wall cpu calls allocations) vals = keys.map { |k| hash[k] } new(*vals).tap do |line| line.instance_variable_set(:@id, id) if id end end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/speed_gun/source.rb', line 28 def to_hash { line: line, code: code, wall: wall, cpu: cpu, calls: calls, allocations: allocations } end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/speed_gun/source.rb', line 24 def to_s format('% 8.1fms + % 8.1fms (% 5d) % 5d allocs | %04d %s', cpu / 1000.0, (wall - cpu) / 1000.0, calls, allocations, line, code) end |