I found wxruby2.so in mingw release a bit large (18M), it is smaller (~15M) after stripping symbols. I learned this from http://wiki.wxwidgets.org/Reducing_Executable_Size . 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). -- Posted via http://www.ruby-forum.com/.
Chauk-Mean Proum
2010-Feb-08 18:17 UTC
[wxruby-users] Suggestions to reduce binary size, make loading faster
Hi Lui, 2010/2/4 Lui Kore <lists at ruby-forum.com>:> I found wxruby2.so in mingw release a bit large (18M), it is smaller > (~15M) after stripping symbols. I learned this from > http://wiki.wxwidgets.org/Reducing_Executable_Size . The command line > is: > > ? ?strip --strip-all wxruby2.soWe already use strip -x. But strip --strip-all seems to reduce the size a little more. I''ll try and see if there is no problem.> 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/Interesting. I''ll take a look at it. Cheers. Chauk-Mean.
Chauk-Mean Proum
2010-Sep-09 20:08 UTC
[wxruby-users] Suggestions to reduce binary size, make loading faster
Hi Lui, 2010/2/4 Lui Kore <lists at ruby-forum.com>:> 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/ >Sorry for such a long delay ... I''ve tested your suggestion and indeed the loading is a bit faster. But the improvement is only about 10-11% on my system according to a Benchmark.measure of a require ''wx''. I don''t know yet if it is worth adding a rake task for generating the classes.rb automatically even if I''ve already written it. Does anybody has an opinion on the subject ? Cheers. Chauk-Mean.