Skip to content

Instantly share code, notes, and snippets.

View vassilios's full-sized avatar

Vassilis Liatsos vassilios

  • Tradelegs LLC
  • New York
View GitHub Profile
@vassilios
vassilios / test_yaml.rb
Created March 21, 2018 00:54
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) }
@vassilios
vassilios / test_openssl.rb
Created June 2, 2017 16:01
Benchmark for OpenSSL::Cipher#random_iv
require 'benchmark'
require 'openssl'
Benchmark.bm do |x|
10.times do
x.report do
cipher = OpenSSL::Cipher.new('bf-cbc')
cipher.random_iv
end
end