Skip to content

Commit

Permalink
Remove benchmark dependency
Browse files Browse the repository at this point in the history
It's only used for one method that is easily replaceable by build in methods
  • Loading branch information
Earlopain committed Dec 14, 2023
1 parent d7a14bf commit 7fd60a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
31 changes: 15 additions & 16 deletions lib/solargraph/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,24 @@ def typecheck *files
option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.'
option :verbose, type: :boolean, aliases: :v, desc: 'Verbose output', default: false
def scan
require 'benchmark'
directory = File.realpath(options[:directory])
api_map = nil
time = Benchmark.measure {
api_map = Solargraph::ApiMap.load(directory)
api_map.pins.each do |pin|
begin
puts pin_description(pin) if options[:verbose]
pin.typify api_map
pin.probe api_map
rescue StandardError => e
STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}"
STDERR.puts "[#{e.class}]: #{e.message}"
STDERR.puts e.backtrace.join("\n")
exit 1
end
time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
api_map = Solargraph::ApiMap.load(directory)
api_map.pins.each do |pin|
begin
puts pin_description(pin) if options[:verbose]
pin.typify api_map
pin.probe api_map
rescue StandardError => e
STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}"
STDERR.puts "[#{e.class}]: #{e.message}"
STDERR.puts e.backtrace.join("\n")
exit 1
end
}
puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds."
end
elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start
puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{elapsed_time} seconds."
end

desc 'list', 'List the files in the workspace and the total count'
Expand Down
1 change: 0 additions & 1 deletion solargraph.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.6'

s.add_runtime_dependency 'backport', '~> 1.2'
s.add_runtime_dependency 'benchmark'
s.add_runtime_dependency 'bundler', '~> 2.0'
s.add_runtime_dependency 'diff-lcs', '~> 1.4'
s.add_runtime_dependency 'e2mmap'
Expand Down

0 comments on commit 7fd60a3

Please sign in to comment.