Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Performance

Eric Anderson edited this page · 3 revisions

Some people have expressed concern about performance since the Test blocks are executed even when you are not testing. This is mostly a non-issue for a few reasons.

1. The Test blocks generally only execute at load time. So once your app is loaded then it is like they are not there.
2. When not testing the Test block simply returns. So it is almost a no-op and doesn’t even store the block so no memory loss.
3. If it REALLY bothered you, then just define Kernel#Test as a no-op when not testing. For example:


# Stubs in dev or prod mode
module Kernel
  def Test(*args, &blk); end
  def ForTest(*args, &blk); end
end unless respond_to? :Test

Now you just have an empty method call which the runtime might even be able to optimize out.

Something went wrong with that request. Please try again.