I found wxruby2.so in mingw release a bit large (18M), it is smaller
(~15M) after stripping symbols. I learned this from
Reducing Executable Size - WxWiki . The command line
is:
strip --strip-all wxruby2.so
But I don’t know whether there is a problem with stripping, at least my
app still runs well with the stripped one.
The loading of wxruby is not very fast too(~ 1.3s on my machine). After
a small profile, I found the following code in wx.rb the bottle-neck:
require 'wx/classes/evthandler.rb'
class_files = File.join( File.dirname(__FILE__), 'wx', 'classes',
‘*.rb’)
Dir.glob(class_files) do | class_file |
require ‘wx/classes/’ + class_file[/\w+.rb$/]
end
A simple improvement is to make wx/classes/*.rb into one.
I wrote the following script, placed it under wx/, then run it to
generate a new classes.rb containing most classes under wx/classes/
data = []
(Dir.glob('classes/*.rb') - [
'classes/evthandler.rb',
'classes/simplehelpprovider.rb',
'classes/bitmap.rb'
]).each do |f|
data.push File.read f
end
File.open 'classes.rb', 'w' do |f|
f.puts data.join "\n"
end
Then I changed the classes loading section in wx.rb with:
require 'wx/classes/evthandler.rb'
require 'wx/classes.rb'
After this modification, the loading time seems shorter (reduced to ~
0.4s on my machine).