MovementManager.new(playerObject.getMovementProxy()).go(targetRoom.getDestinationProxy())
require "benchmark"
class ExceptionBenchmark
def begin(iter)
Benchmark.bmbm(10) do |bm|
bm.report("exception") { iter.times { test_exception() } }
bm.report("return") { iter.times { test_return() } }
end
end
def test_exception()
begin
method_one();
rescue Exception;
end;
end
def test_return()
if method_two() == false
end
end
def method_one()
raise Exception
end
def method_two()
false
end
end
bm = ExceptionBenchmark.new()
bm.begin(100_000)
Rehearsal ———————————————
exception 1.300000 0.130000 1.430000 ( 1.468609)
return 0.140000 0.050000 0.190000 ( 0.183466)
———————————— total: 1.620000sec
user system total real
exception 1.290000 0.160000 1.450000 ( 1.521496)
return 0.130000 0.050000 0.180000 ( 0.177468)
require 'benchmark'
def raises_somefin
raise
end
def raises_noffin
end
Benchmark.bm do |b|
b.report("When raised: ") do
100000.times do
begin
raises_somefin
rescue
next
end
end
end
b.report("No raise: ") do
100000.times do
begin
raises_noffin
rescue
next
end
end
end
end
It's a specific exception I've defined to be associated with actions that can be taken by objects such as entering an exit.
Generally I would consider (in my own world, especially) an exception to be something, er, exceptional. Like if the exit was actually supposed to exist but somehow had been dereferenced for example. You know implicitly that an exit may not be able to be entered, so its not really an "exceptional" circumstance, you can handle it with logic, and probably should.
I wouldn't advocate doing it that way, but as I say, each to their own :D
Sounds like you are making up arbitrary rules for what an exception has to be.