Skip to content

Instantly share code, notes, and snippets.

@rbnpercy
Created November 11, 2019 15:33
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 rbnpercy/a3e33ef4937eb46b5166b5ce919c04c6 to your computer and use it in GitHub Desktop.
Save rbnpercy/a3e33ef4937eb46b5166b5ce919c04c6 to your computer and use it in GitHub Desktop.
require "base64"
STR_SIZE = 131072
TRIES = 8192
str = "a" * STR_SIZE
str2 = Base64.strict_encode(str)
print "encode #{str[0..3]}... to #{str2[0..3]}...: "
t, s = Time.local, 0
TRIES.times do |i|
str2 = Base64.strict_encode(str)
s += str2.bytesize
end
puts "#{s}, #{Time.local - t}"
str3 = Base64.decode_string(str2)
print "decode #{str2[0..3]}... to #{str3[0..3]}...: "
t, s = Time.local, 0
TRIES.times do |i|
str3 = Base64.decode_string(str2)
s += str3.bytesize
end
puts "#{s}, #{Time.local - t}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment