I wrote a script to use active_record without rails. My tests are on windows 7 (Trendmicro Virus protection enabled – can’t disable it because the notebook is property of my company), Lenovo T520. I wrote a little tk script that started in about a second. I added the ‘sqlite3’ gem and it started in 2 seconds.
After requiring the ‘active_record’ gem startup time when up to 30 seconds!!
Can I do something against that (please don’t recommend changing the os)? Is ruby just for use with rails so that it can run on a unix box where the performance is ok?
Versions are:
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
activerecord (3.2.2)
Edit: Something interesting happened. After starting the script a few times “requiring ‘active_record'” is done in 0.53 seconds. Maybe it’s os-caching or virus protection ignores the files because it considers them safe. After a fresh reboot the time went up to 3.5 seconds on the first run and dropped again on the second run to the known 0.53 seconds.
I have an somehow acceptable solution. It depends on the order the modules are required:
Startup 30 seconds:
require ‘tk’
require ‘active_record’
Startup 2 seconds:
require ‘active_record’
require ‘tk’
IMHO this thing is answered (but I’m not really satisfied).