Class: CyberarmEngine::Stats::Frame
- Inherits:
-
Object
- Object
- CyberarmEngine::Stats::Frame
- Defined in:
- lib/cyberarm_engine/stats.rb
Defined Under Namespace
Classes: Timing
Instance Attribute Summary collapse
-
#counters ⇒ Object
readonly
Returns the value of attribute counters.
-
#frame_timing ⇒ Object
readonly
Returns the value of attribute frame_timing.
-
#multitimings ⇒ Object
readonly
Returns the value of attribute multitimings.
-
#timings ⇒ Object
readonly
Returns the value of attribute timings.
Instance Method Summary collapse
- #attempted_multitiming? ⇒ Boolean
- #complete ⇒ Object
- #complete? ⇒ Boolean
- #end_timing(key) ⇒ Object
- #increment(key, number = 1) ⇒ Object
-
#initialize ⇒ Frame
constructor
A new instance of Frame.
- #start_timing(key) ⇒ Object
Constructor Details
#initialize ⇒ Frame
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cyberarm_engine/stats.rb', line 46 def initialize @frame_timing = Timing.new(Gosu.milliseconds, -1, -1) @attempted_multitiming = false @counters = { gui_recalculations: 0 } @timings = {} @multitimings = {} end |
Instance Attribute Details
#counters ⇒ Object (readonly)
Returns the value of attribute counters.
45 46 47 |
# File 'lib/cyberarm_engine/stats.rb', line 45 def counters @counters end |
#frame_timing ⇒ Object (readonly)
Returns the value of attribute frame_timing.
45 46 47 |
# File 'lib/cyberarm_engine/stats.rb', line 45 def frame_timing @frame_timing end |
#multitimings ⇒ Object (readonly)
Returns the value of attribute multitimings.
45 46 47 |
# File 'lib/cyberarm_engine/stats.rb', line 45 def multitimings @multitimings end |
#timings ⇒ Object (readonly)
Returns the value of attribute timings.
45 46 47 |
# File 'lib/cyberarm_engine/stats.rb', line 45 def timings @timings end |
Instance Method Details
#attempted_multitiming? ⇒ Boolean
102 103 104 |
# File 'lib/cyberarm_engine/stats.rb', line 102 def attempted_multitiming? @attempted_multitiming end |
#complete ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cyberarm_engine/stats.rb', line 87 def complete @frame_timing.end_time = Gosu.milliseconds @frame_timing.duration = @frame_timing.end_time - @frame_timing.start_time # Lock data structures @frame_timing.freeze @counters.freeze @timings.freeze @multitimings.freeze end |
#complete? ⇒ Boolean
98 99 100 |
# File 'lib/cyberarm_engine/stats.rb', line 98 def complete? @frame_timing.duration != -1 end |
#end_timing(key) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/cyberarm_engine/stats.rb', line 77 def end_timing(key) timing = @timings[key] # FIXME: Make it not spammy... # warn "Timing #{key.inspect} already ended!" if timing.end_time != -1 timing.end_time = Gosu.milliseconds timing.duration = timing.end_time - timing.start_time end |
#increment(key, number = 1) ⇒ Object
58 59 60 61 |
# File 'lib/cyberarm_engine/stats.rb', line 58 def increment(key, number = 1) @counters[key] ||= 0 @counters[key] += number end |
#start_timing(key) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cyberarm_engine/stats.rb', line 63 def start_timing(key) raise "key must be a symbol!" unless key.is_a?(Symbol) if @timings[key] # FIXME: Make it not spammy... # warn "Only one timing per key per frame. (Timing for #{key.inspect} already exists!)" @attempted_multitiming = true @multitimings[key] = true return end @timings[key] = Timing.new(Gosu.milliseconds, -1, -1) end |