Closed hawx closed 13 years ago
Sorry I was being stupid and not looking at the code as I went through. facepalm
I had a thought today, when running from the command line as an installed gem (ie. not in development running bin/beats song.txt
) you are actually calling $GEM_HOME/bin/beats
which loads rubygems in it before loading the gem. So really it would be a lot more convenient to just install wavefile as a gem as you only see the performance gain when running from within the repo. Here's what $GEM_HOME/bin/beats
looks like, note line 9:
#!/Users/Josh/.rvm/rubies/ruby-1.9.2-head/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'beats' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'beats', version
load Gem.bin_path('beats', 'beats', version)
Thanks for pointing that out. I did some testing, and the performance hit from using rubygems in 1.8.7 was an artifact of how I was running it in development. When running as an installed gem, the performance is the same for both require 'wavefile'
and require 'lib/wavefile'
, and is just as fast as running in development using lib/wavefile
. The only time I notice a slowdown is running in development using the gem.
I tested using 1.8.7 and 1.9.2 with RVM, and with the version of 1.8.7 that comes pre-installed on Snow Leopard. I tested by modifying the installed gem to switch between using wavefile
and lib/wavefile
(i.e. by editing $GEM_HOME/bin/beats
). In all 3 Ruby versions, the performance was the same for both wavefile
and lib/wavefile
.
I've removed lib/wavefile
and updated the gemspec, so closing this out.
You need to add wavefile as a dependency to the gemspec so that it is installed by adding:
Excellent work on the library by the way!