summaryrefslogtreecommitdiff
path: root/bin/ffi-yajl-bench
blob: 410c5e05c398411f90d578b3a3b9f584ea28f5df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby


$: << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))

require 'optparse'
require 'ffi_yajl/benchmark'

opts = {}
optparse = OptionParser.new do |o|
  o.banner = "Usage: ffi-yajl-bench"

  opts[:profile] = false
  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
  FFI_Yajl::Benchmark::Encode.new().run()
end