Module: Draco::Benchmark::WorldPlugin

Defined in:
lib/draco/benchmark.rb

Overview

Internal: The module containing the benchmark plugin for Draco::World.

Instance Method Summary collapse

Instance Method Details

#after_tick(context, results) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/draco/benchmark.rb', line 18

def after_tick(context, results)
  super
  results.each do |system|
    name = Draco.underscore(system.class.name.to_s).to_sym
    @system_timer_data[name] = (system.timer * 1000.0).round(5)
  end
  puts @system_timer_data.inspect if (context.tick_count % 10).zero?
end

#before_tick(context) ⇒ Object



13
14
15
16
# File 'lib/draco/benchmark.rb', line 13

def before_tick(context)
  @system_timer_data = Hash.new { |h, k| h[k] = [] }
  super.each { |system| system.class.prepend(SystemPlugin) }
end

#system_timersObject



27
28
29
# File 'lib/draco/benchmark.rb', line 27

def system_timers
  @system_timer_data.sort_by { |_k, v| -v }.to_h
end