File: require_path_checker.rb

package info (click to toggle)
ruby-did-you-mean 1.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: ruby: 2,701; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,196 bytes parent folder | download | duplicates (2)
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