Created
July 21, 2021 17:45
-
-
Save manuelpuyol/a0f1b5a2840315e3c7d6fc3144d86ca5 to your computer and use it in GitHub Desktop.
Create a copy of the old `Primer::Classify::Utilities` and rename it `Primer::Classify::UtilitiesOld` before running
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
# frozen_string_literal: true | |
require "benchmark" | |
require_relative "lib/primer/classify/utilities" | |
require_relative "lib/primer/classify/utilities_old" | |
# make sure YML is loaded | |
Primer::Classify::Utilities::UTILITIES | |
Primer::Classify::UtilitiesOld::UTILITIES | |
runs = [10_000, 50_000, 100_000] | |
runs.each do |n| | |
puts "Running #{n} times." | |
Benchmark.bm do |benchmark| | |
benchmark.report("Old") do | |
n.times do | |
Primer::Classify::UtilitiesOld.classes_to_hash("mr-1 d-md-block hide-sm anim-fade-in foo") | |
end | |
end | |
benchmark.report("New") do | |
n.times do | |
Primer::Classify::Utilities.classes_to_hash("mr-1 d-md-block hide-sm anim-fade-in foo") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment