From 5d98291bb443f732e626faa911c660405487def8 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 15 Sep 2026 18:01:45 +0200 Subject: [PATCH] Drop the `benchmark` dependency It is trivial, don't have to take on a dependency for that. The test change is because activesupport 7.1.0 itself doesn't depend on `benchmark` properly --- Gemfile.lock | 1 - lib/tapioca/helpers/rbi_files_helper.rb | 13 ++++++++++--- lib/tapioca/internal.rb | 1 - spec/tapioca/cli/gem_spec.rb | 4 ++-- tapioca.gemspec | 1 - 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 885dff7c2..c6e15d193 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,7 +15,6 @@ PATH remote: . specs: tapioca (0.20.0) - benchmark bundler (>= 2.2.25) netrc (>= 0.11.0) parallel (>= 1.21.0) diff --git a/lib/tapioca/helpers/rbi_files_helper.rb b/lib/tapioca/helpers/rbi_files_helper.rb index fabe82cb2..40c4cb70e 100644 --- a/lib/tapioca/helpers/rbi_files_helper.rb +++ b/lib/tapioca/helpers/rbi_files_helper.rb @@ -10,7 +10,7 @@ def index_rbi(index, kind, file) return unless File.exist?(file) say("Loading #{kind} RBIs from #{file}... ") - time = Benchmark.realtime do + time = realtime do parse_and_index_files(index, [file], number_of_workers: 1) end say(" Done ", :green) @@ -26,7 +26,7 @@ def index_rbis(index, kind, dir, number_of_workers:) else say("Loading #{kind} RBIs from #{dir}... ") end - time = Benchmark.realtime do + time = realtime do files = Dir.glob("#{dir}/**/*.rbi").sort parse_and_index_files(index, files, number_of_workers: number_of_workers) end @@ -38,7 +38,7 @@ def index_rbis(index, kind, dir, number_of_workers:) def duplicated_nodes_from_index(index, shim_rbi_dir:, todo_rbi_file:) duplicates = {} say("Looking for duplicates... ") - time = Benchmark.realtime do + time = realtime do index.keys.each do |key| nodes = index[key] next unless shims_or_todos_have_duplicates?(nodes, shim_rbi_dir: shim_rbi_dir, todo_rbi_file: todo_rbi_file) @@ -380,5 +380,12 @@ def update_gem_rbis_strictnesses(errors, gem_dir) def gem_name_from_rbi_path(path) T.must(File.basename(path, ".rbi").split("@").first) end + + #: ?{ (?) -> untyped } -> (Integer | Float) + def realtime(&block) + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + yield + Process.clock_gettime(Process::CLOCK_MONOTONIC) - start + end end end diff --git a/lib/tapioca/internal.rb b/lib/tapioca/internal.rb index d7fa4bbda..11fc21f09 100644 --- a/lib/tapioca/internal.rb +++ b/lib/tapioca/internal.rb @@ -28,7 +28,6 @@ require "tapioca/rbs/rewriter" # ^ Do not change the order of these requires -require "benchmark" require "bundler" require "erb" require "etc" diff --git a/spec/tapioca/cli/gem_spec.rb b/spec/tapioca/cli/gem_spec.rb index 64c0dd516..70199bb38 100644 --- a/spec/tapioca/cli/gem_spec.rb +++ b/spec/tapioca/cli/gem_spec.rb @@ -687,7 +687,7 @@ class Secret; end end it "must not include code from an ActiveSupport.on_load hook in ActiveRecord RBIs" do - @project.require_real_gem("rails", "7.1.0") + @project.require_real_gem("rails", "7.1.6") # Flipper adds functionality to ActiveRecord via an ActiveSupport.on_load hook @project.require_real_gem("flipper-active_record", "1.3.1") @@ -698,7 +698,7 @@ class Secret; end assert_success_status(result) activerecord_rbi_file = T.must( - Dir.glob("#{@project.absolute_path}/sorbet/rbi/gems/activerecord@7.1.0.rbi").first, + Dir.glob("#{@project.absolute_path}/sorbet/rbi/gems/activerecord@7.1.6.rbi").first, ) refute_includes(File.read(activerecord_rbi_file), "class Flipper") end diff --git a/tapioca.gemspec b/tapioca.gemspec index 96971e4df..846c421ae 100644 --- a/tapioca.gemspec +++ b/tapioca.gemspec @@ -23,7 +23,6 @@ Gem::Specification.new do |spec| spec.metadata["allowed_push_host"] = "https://rubygems.org" - spec.add_dependency("benchmark") spec.add_dependency("bundler", ">= 2.2.25") spec.add_dependency("netrc", ">= 0.11.0") spec.add_dependency("parallel", ">= 1.21.0")