Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elvanja/4525311 to your computer and use it in GitHub Desktop.
Save elvanja/4525311 to your computer and use it in GitHub Desktop.
require_relative '../../../spec/spec_helper_without_rails'
require_relative 'amazon_search_response_parser_crack_hashie'
response = OpenStruct.new(body: File.read('spec/fixtures/amazon_api_responses/search_response_multiple_items.xml'))
result = AmazonSearchResponseParser.new.parse(response)
tests_to_run = 100
start = Time.now
tests_to_run.times { AmazonSearchResponseParser.new.parse(response) }
nokogiri = Time.now - start
start = Time.now
tests_to_run.times { AmazonSearchResponseParserCrackHashie.new.parse(response) }
crack_hashie = Time.now - start
puts "Test results parsing Amazon response with #{result.items.size} items in #{tests_to_run} consecutive runs"
puts "Nokogiri: #{nokogiri} seconds"
puts "Crack & Hashie: #{crack_hashie} seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment