Sha256: 5b110aa2955d5a612e3cd1e0a6659fadf8befe2cf45b3b609f49c729e4a72cee

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 Bytes

Contents

require 'benchmark'
require '../lib/gamebox'

class BoxedActor
  include Kvo
  kvo_attr_accessor :x, :y
  attr_accessor :w, :h

  can_fire_anything

  def initialize(x,y,w,h)
    @kvo_x = x
    @kvo_y = y
    @w = w
    @h = h
  end

end
require 'perftools'
PerfTools::CpuProfiler.start("/tmp/perf.txt")


NUM = 1_000
# Benchmark.bm(60) do |b|
#   b.report("full") do
    tree = SpatialTreeStagehand.new :thing, :thing

    thing = BoxedActor.new 1, 2, 3, 4
    tree.add thing
    things = []
    100.times do |i|
      t = BoxedActor.new i, i, i, i
      things << t
      tree.add t
    end

    NUM.times do 
      it = BoxedActor.new 1, 2, 3, 4
      tree.add it

      thing.x + 1
      things[20..40].each do |t|
        t.x += rand(40)-20
      end

      tree.neighbors_of thing do
      end
      tree.remove it
    end
#   end
# end

PerfTools::CpuProfiler.stop
# be pprof.rb --text /tmp/perf.txt


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc5 script/perf_aabb.rb
gamebox-0.4.0.rc4 script/perf_aabb.rb
gamebox-0.4.0.rc3 script/perf_aabb.rb
gamebox-0.4.0.rc2 script/perf_aabb.rb
gamebox-0.4.0.rc1 script/perf_aabb.rb