Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created March 22, 2012 05:46
Show Gist options
  • Select an option

  • Save rondale-sc/2156488 to your computer and use it in GitHub Desktop.

Select an option

Save rondale-sc/2156488 to your computer and use it in GitHub Desktop.
string-theory
# ./test_single_or_double.rb
require './stats.rb'
test_strings = {:double => 'ruby -e "start_time = Time.now; 100_000.times { \"a\" }; puts Time.now - start_time"',
:single => "ruby -e \"start_time = Time.now; 100_000.times { 'a' }; puts Time.now - start_time\""}
sr = 1000.times.inject([]) {|memo, result| memo << `#{test_strings[:single]}`.strip }
dr = 1000.times.inject([]) {|memo, result| memo << `#{test_strings[:double]}`.strip }
single_quotes = Stats.new(sr)
double_quotes = Stats.new(dr)
single_quotes.to_csv("/path/to/file/single_quote_#{RUBY_VERSION}.csv")
double_quotes.to_csv("/path/to/file/double_quote_#{RUBY_VERSION}.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment