Skip to content

Instantly share code, notes, and snippets.

@vassilios
Created March 21, 2018 00:54
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 vassilios/ddbbb499aaa0d4cdd241d6c7e06f08eb to your computer and use it in GitHub Desktop.
Save vassilios/ddbbb499aaa0d4cdd241d6c7e06f08eb to your computer and use it in GitHub Desktop.
Benchmark for YAML with JSON strings
require 'securerandom'
require 'yaml'
require 'json'
require 'benchmark'
hash = { values: 5000.times.collect{ SecureRandom.random_number } }
yaml_hash = { json: hash.to_json }
yaml_string = YAML.dump(yaml_hash)
puts JRUBY_VERSION
puts Benchmark.measure { YAML.load(yaml_string) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment