Skip to content

Instantly share code, notes, and snippets.

@akeem
Created November 11, 2013 16:08
Show Gist options
  • Save akeem/7415657 to your computer and use it in GitHub Desktop.
Save akeem/7415657 to your computer and use it in GitHub Desktop.
json encoding an image 100 times by default
# Loads a random papers image and encodes to to a base64 string and put's it into a json and
# # then decodes it a set amount of times.
# usage: ruby json_decoding.rb [NUM_RUNS]
require 'json'
require 'base64'
if ARGV[0]
n = ARGV[0].to_i
else
n = 100
end
json = JSON.generate({:image => Base64.strict_encode64(File.read("./something.jpg"))})
n.times do |i|
JSON.load json
end
GC.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment