ruby安装
根据编译安装时的c编译环境,ruby被编译成对应的平台版本,如默认无标识的unix(cc、gcc)、freebsd、mingw32、cygwin、mswin32-60(vc6.0)、mswin32-100(vc10.0)、darwin-11(Mac)、java
一些用到c的rubygem,有的被做成多个平台版本,有的只有默认版本,安装和用要注意平台版本匹配
mingw gcc可以编译一些含POSIX FUNCTION的c代码,可在mingw下编译安装ruby
./configure --enable-rubygems --disable-install-doc --disable-install-rdoc --disable-install-capimake && make install
VC6EN\COMMON\MSDEV98\BINVC6EN\VC98\BINVC6EN\VC98\INCLUDEVC6EN\VC98\LIB
# PathC:\VC6EN\COMMON\MSDEV98\BIN;C:\VC6EN\VC98\BIN;%path%;# includeC:\VC6EN\VC98\INCLUDE# libC:\VC6EN\VC98\LIB
C:cd \rubywin32\configurenmake & nmake test & nmake install
%path%;C:\usr\bin;
C:\yaml-0.1.4\win32\vs2008\Output\Debug\lib\DLL;%path%C:\yaml-0.1.4\win32\vs2008\Output\Debug\lib\DLL;%lib%C:\yaml-0.1.4\include;%include%cd %src%\ext\psych && ruby extconf.rb && nmake && nmake install
C:\zlib125-dll;%path%cd %src%\ext\zlib && ruby extconf.rb --with-zlib-dir="C:\zlib125-dll" && nmake && nmake install
cd ext/openssl && ruby extconf.rb --with-openssl-dir="C:\openssl" && nmake && nmake install
gem i -l rubygems-update-x.x.xx.gemupdate_rubygems
# sublime 比 rubymine 好用多了70414-12042010 00002VG0BeoZbwmNAMNCx5E882rBEM Ysn1P!e"s830EDlHcWg8gmqYVkvZMo Injf4yqlO1yy"82NiwNzyYInoT7AiX
require 'benchmark'puts RUBY_PLATFORMsum = 010.times do bm = Benchmark.realtime do arr = [] 20000.times do arr << "ruby platform vs " * 1000 end arr.each do |a| puts 'true' if a =~ /unknown/ end end puts "#{"%0.3f" % bm}s" sum += bmendputs "Average:#{"%0.3f" % (sum / 10)}"
i386-mingw32Average:0.927i686-linuxAverage:0.804i386-freebsd9.0Average:3.872
i386-mswin32Average:0.671i386-mingw32Average:0.633i386-cygwinAverage:0.339
require 'benchmark'class Foo def bar true endendputs RUBY_PLATFORMn = 1_000_000Benchmark.bm(30) do | b | b.report "instance_variable_set" do n.times do instance = Foo.new instance.instance_variable_set(:@baz, Hash.new) end end b.report "instance_eval" do n.times do instance = Foo.new instance.instance_eval do @baz = Hash.new end end endend
i386-mingw32 user system total realinstance_variable_set 1.295000 0.000000 1.295000 ( 1.290073)instance_eval 2.637000 0.000000 2.637000 ( 2.629151)i386-cygwin user system total realinstance_variable_set 1.622000 0.000000 1.622000 ( 1.622093)instance_eval 3.994000 0.000000 3.994000 ( 4.002229)