summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-11-18 22:48:44 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2013-11-18 22:48:44 -0800
commitcd49dd7a175b0acae2700b5e8808b70f03e39a8f (patch)
tree81ed93e4f0c967c12887033609fc0230a351a192
parented1b6042be66637e8f5b543c6876d1302af2fc2f (diff)
downloadffi-yajl-cd49dd7a175b0acae2700b5e8808b70f03e39a8f.tar.gz
get the c extensions compiled in
-rw-r--r--.travis.yml3
-rwxr-xr-xbin/ffi-yajl-bench11
-rw-r--r--lib/ffi_yajl/benchmark/encode.rb12
3 files changed, 21 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml
index 3dd5593..d947287 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
before_install: sudo dpkg -P libyajl1 || true
-script: rake install ; lib=`gem which ffi_yajl`; dirname=`dirname $lib`; cd $dirname/..; rspec
+ # this would probably all be easier if i fixed bundle install not working...
+script: rake gem ; gem install pkg/ffi-yajl*.gem ; lib=`gem which ffi_yajl`; dirname=`dirname $lib`; cd $dirname/..; rspec
after_success: gem install yajl-ruby; gem install json; gem install psych; ffi-yajl-bench
language: ruby
rvm:
diff --git a/bin/ffi-yajl-bench b/bin/ffi-yajl-bench
index 13725a0..410c5e0 100755
--- a/bin/ffi-yajl-bench
+++ b/bin/ffi-yajl-bench
@@ -14,10 +14,21 @@ optparse = OptionParser.new do |o|
o.on( '-p', '--profile', 'Run perftools.rb profiling' ) do
opts[:profile] = true
end
+
+ o.on( '-F', '--ffi', 'Force using FFI' ) do
+ opts[:ffi] = true
+ end
+
+ o.on( '-E', '--ext', 'Force using C ext' ) do
+ opts[:ext] = true
+ end
end
optparse.parse!
+ENV['FORCE_FFI_YAJL'] = 'ffi' if opts[:ffi]
+ENV['FORCE_FFI_YAJL'] = 'ext' if opts[:ext]
+
if opts[:profile]
FFI_Yajl::Benchmark::EncodeProfile.new().run()
else
diff --git a/lib/ffi_yajl/benchmark/encode.rb b/lib/ffi_yajl/benchmark/encode.rb
index fbeb503..a3edfe3 100644
--- a/lib/ffi_yajl/benchmark/encode.rb
+++ b/lib/ffi_yajl/benchmark/encode.rb
@@ -5,10 +5,14 @@ require 'rubygems'
require 'benchmark'
require 'stringio'
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
- begin
- require 'yajl'
- rescue Exception
- puts "INFO: yajl-ruby not installed"
+ if ENV['FORCE_FFI_YAJL'] != 'ext'
+ begin
+ require 'yajl'
+ rescue Exception
+ puts "INFO: yajl-ruby not installed"
+ end
+ else
+ puts "INFO: skipping yajl-ruby because we're using the C extension"
end
else
puts "INFO: skipping yajl-ruby on jruby"