1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
# frozen-string-literal: true
#
# Run the following command to run this script:
#
# $ ruby --disable-did_you_mean benchmark/require_path_checker.rb
#
require_relative '../lib/did_you_mean/spell_checkers/require_path_checker'
require 'benchmark/ips'
Benchmark.ips do |x|
x.config(time: 10, warmup: 10)
exception_with_slash = begin
require 'net/htto'
rescue LoadError => error
error
end
exception_without_slash = begin
require 'net-http'
rescue LoadError => error
error
end
checker_for_path = DidYouMean::RequirePathChecker.new(exception_with_slash)
checker_for_file = DidYouMean::RequirePathChecker.new(exception_without_slash)
x.report "original (with a /)" do
checker_for_path.corrections
end
x.report "original (without /)" do
checker_for_file.corrections
end
#x.report "proposed (with a /)" do
# checker_for_path.experiment
#end
#
#x.report "proposed (without /)" do
# checker_for_file.experiment
#end
x.compare!
end
|