I was doing some work profiling the ‘assets:precompile’ Rake task in a
JRuby on Rails app, and I discovered some interesting performance
related to doing things like this:
begin file.actions() rescue Errno::ENOENT # ignore or do something end
instead of this:
if File.exists?(file) file.actions() else # ignore or do something end
I started submitting a few small patches, but already met with pushback
because the issue was perceived to only affect JRuby and assumed
to lower performance in MRI.
I wrote up a simple benchmark testing counting directory entries for
directories that may or may not exist. I would appreciate any feedback
on this specific benchmark and on the general idioms of exception
vs. explicit test, neither of which are “free”.