From 7fd60a3f90e8cf16528bcffcfa59e2149944ee61 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 14 Dec 2023 10:42:55 +0100 Subject: [PATCH] Remove benchmark dependency It's only used for one method that is easily replaceable by build in methods --- lib/solargraph/shell.rb | 31 +++++++++++++++---------------- solargraph.gemspec | 1 - 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 7800cef92..128375591 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -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' diff --git a/solargraph.gemspec b/solargraph.gemspec index 7be8dcb73..bd5f8bebb 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -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'