Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'benchmark'
actioncable_folder = '/rails/actioncable'
rubocop_folder = '/rubocop'
def reset_rails(actioncable_folder)
Dir.chdir(actioncable_folder) do
system('git checkout -f v5.2.3 >/dev/null 2>&1')
system('mv ../.rubocop.yml ../.rubocop.yml_bk')
end
end
def reset_rubocop(branch_name, rubocop_folder)
Dir.chdir(rubocop_folder) do
system("git checkout #{branch_name} >/dev/null 2>&1")
end
end
def do_rubocop(option, rubocop_folder, actioncable_folder)
reset_rails(actioncable_folder)
system("bundle exec ruby ./exe/rubocop #{actioncable_folder} #{option} >/dev/null 2>&1")
end
# small test
::Benchmark.bm(18) do |r|
option = ' --auto-correct --parallel'
Dir.chdir(rubocop_folder) do
reset_rubocop("feature/auto_correct_support_parallel", rubocop_folder)
# warmup
do_rubocop(option, rubocop_folder, actioncable_folder)
r.report("with parallel") { 10.times { do_rubocop(option, rubocop_folder, actioncable_folder) } }
end
option = ' --auto-correct'
Dir.chdir(rubocop_folder) do
reset_rubocop("feature/auto_correct_support_parallel", rubocop_folder)
# warmup
do_rubocop(option, rubocop_folder, actioncable_folder)
r.report("without parallel") { 10.times { do_rubocop(option, rubocop_folder, actioncable_folder) } }
end
option = ' --auto-correct'
Dir.chdir(rubocop_folder) do
reset_rubocop("fffd4e6278ff47783b8055dcad00f01b67fff4ff", rubocop_folder)
# warmup
do_rubocop(option, rubocop_folder, actioncable_folder)
r.report("origin/master") { 10.times { do_rubocop(option, rubocop_folder, actioncable_folder) } }
end
end
@ota42y
Copy link
Author

ota42y commented Jun 28, 2019

The result

user system total real
with parallel 0.004295 0.019300 165.135620 ( 65.099195 )
without parallel 0.003868 0.017207 95.377579 ( 96.922844 )
origin/master 0.003889 0.018306 94.157648 ( 95.972828 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment