Created
November 11, 2013 16:08
-
-
Save akeem/7415657 to your computer and use it in GitHub Desktop.
json encoding an image 100 times by default
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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