<commit_before>$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'
require 'gson'
require 'optparse'
begin
  require 'json'
rescue LoadError
end

options = {
  :times => 1_000,
  :file => File.expand_path(File.dirname(__FILE__) + '/subjects/ohai.json'),
  :type => :both
}

OptionParser.new do |opts|
  opts.banner = "Usage: benchmark.rb [options]"
  opts.on("-t", "--type TYPE", [:decode, :encode, :both], "Type of the operation (default: #{options[:type]}") do |v|
    options[:verbose] = v
  end
  opts.on("-n", "--times NUMBER", Integer, "Number of iterations (default: #{options[:times]})") do |v|
    options[:times] = v
  end
  opts.on("-f", "--file FILE", "File to use as JSON source (default: #{options[:file]})") do |v|
    options[:file] = v
  end
  opts.on_tail("-?", "--help", "Show this message") do
    puts opts
    exit
  end
end.parse!
<commit_msg>Fix benchmark options<commit_after>$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rubygems'
require 'benchmark'
require 'gson'
require 'optparse'
begin
  require 'json'
rescue LoadError
end

options = {
  :times => 1_000,
  :file => File.expand_path(File.dirname(__FILE__) + '/subjects/ohai.json'),
  :type => :both
}

OptionParser.new do |opts|
  opts.banner = "Usage: benchmark.rb [options]"
  opts.on("-t", "--type TYPE", [:decode, :encode, :both], "Type of the operation (default: #{options[:type]}") do |v|
    options[:type] = v
  end
  opts.on("-n", "--times NUMBER", Integer, "Number of iterations (default: #{options[:times]})") do |v|
    options[:times] = v
  end
  opts.on("-f", "--file FILE", "File to use as JSON source (default: #{options[:file]})") do |v|
    options[:file] = v
  end
  opts.on_tail("-?", "--help", "Show this message") do
    puts opts
    exit
  end
end.parse!

{'fraction_non_alphanumeric': 0.1926743602609132, 'fraction_numerical': 0.004014049172102358, 'mean_word_length': 4.125964010282776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2320928', 'n_tokens_mistral': 712, 'n_tokens_neox': 702, 'n_words': 186}