Created
March 18, 2020 16:56
-
-
Save micke/9ff549865863aa7251657f7b5a0235aa to your computer and use it in GitHub Desktop.
Benchmarks the valid_email2 gem using a YAML file vs TXT as datastore
This file contains hidden or 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
require "yaml" | |
require "benchmark" | |
require "benchmark/memory" | |
iterations = 50 | |
Benchmark.bm do |x| | |
x.report "YAML:" do | |
iterations.times do | |
YAML.load_file("config/disposable_email_domains.yml") | |
end | |
end | |
x.report "TXT: " do | |
iterations.times do | |
File.open("config/disposable_email_domains.txt") do |f| | |
f.read.split("\n") | |
end | |
end | |
end | |
end | |
Benchmark.memory do |x| | |
x.report "YAML:" do | |
YAML.load_file("config/disposable_email_domains.yml") | |
end | |
x.report "TXT: " do | |
File.open("config/disposable_email_domains.txt") do |f| | |
f.read.split("\n") | |
end | |
end | |
x.compare! | |
end |
Author
micke
commented
Mar 18, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment