I am facing a very weird situation on Mac OS X.
This has bee replicated on two Macs (a Macbook and Mac Mini Server).
Essentially I am running the same, identical ruby code in two different directories. In the first directory I have an execution time of 7 seconds and on the second directory 0.191.
There is absolutely no difference among the two.
gspider@b1-3 ~£ time ruby sb2.rb
#<struct recno=2001, name="Amazon", ticker="MPS", tradeprice=185.5, tradedate="2012-04- 28", quantity=45, totalposition=8347.5>
real 0m7.775s
user 0m7.160s
sys 0m0.612s
gspider@b1-3 ~/Sites£ time ruby sb2.rb
#<struct recno=2001, name="Amazon", ticker="MPS", tradeprice=185.5, tradedate="2012-04- 28", quantity=45, totalposition=8347.5>
real 0m0.191s
user 0m0.164s
sys 0m0.023s
but there is more. Even a simple ruby script fetching a non existing file behaves different in the two directories: Notice that it is using the same identical ruby version
gspider@b1-3 ~£ time ruby sb3.rb
/Users/spider/.rvm/gems/ruby-1.9.3-p125/gems/KirbyBase-2.6.1/lib/kirbybase.rb:520:in `get_table': Table not found! (RuntimeError)
from sb3.rb:8:in `<main>'
real 0m7.885s
user 0m7.240s
sys 0m0.642s
gspider@b1-3 ~/Sites£ time ruby sb3.rb
/Users/spider/.rvm/gems/ruby-1.9.3-p125/gems/KirbyBase-2.6.1/lib/kirbybase.rb:520:in `get_table': Table not found! (RuntimeError)
from sb3.rb:8:in `<main>'
real 0m0.183s
user 0m0.156s
sys 0m0.023s
What can be the cause for this highly erratic behavior ? Again this is the same machine as you can see from the bash tag just 2 different directories. I have been able to replicate the same error on another mac but the “infected” path/directory is different so it just looks like randomly some directories /paths get this ruby slow delayed execution curse.
KirkyBase opens all tables ( .tbl files ) in a folder.
If you have more bigger files in some folder and less or smaller files in the other this might explain the difference in time.