From 925f598daf971229b373fb3d3148bbdaf3014b75 Mon Sep 17 00:00:00 2001 From: Peter Boling Date: Tue, 17 Sep 2024 11:22:58 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20RuboCop=20Linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmarks/Gemfile | 2 +- benchmarks/benchmarks.rb | 39 ++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/benchmarks/Gemfile b/benchmarks/Gemfile index 8e96b6d..c122ff9 100644 --- a/benchmarks/Gemfile +++ b/benchmarks/Gemfile @@ -20,8 +20,8 @@ gem "gem_bench", "2.0.1" if RUBY_VERSION > "3" gem "alt_memery", "2.1.0", require: false gem "dry-core", "1.0.1" - gem "memoist3", "1.0.0", require: false gem "memery", "1.6.0" + gem "memoist3", "1.0.0", require: false else gem "ddmemoize", "1.0.0" gem "memoist", "0.16.2" diff --git a/benchmarks/benchmarks.rb b/benchmarks/benchmarks.rb index 3745f5f..fb50803 100644 --- a/benchmarks/benchmarks.rb +++ b/benchmarks/benchmarks.rb @@ -57,9 +57,7 @@ memoization_method: :memoize, }, ), -].each do |re_namespaced_gem| - re_namespaced_gem.doff_and_don # Copies, re-namespaces, and requires each gem. -end +].each(&:doff_and_don) # Copies, re-namespaces, and requires each gem. # Here we require memo_wise gem from the `pwd` source. # Separately, in the Gemfile, we download the main branch of MemoWise from GitHub. @@ -116,24 +114,23 @@ def benchmark_name # using it to minimize the chance that our benchmarks are affected by ordering. # NOTE: Some gems do not yet work in Ruby 3 so we only test with them if they've # been `require`d. -BENCHMARK_GEMS = - (re_namespaced_gems.map {|re_namespaced_gem| - BenchmarkGem.new( - re_namespaced_gem.as_klass, - re_namespaced_gem.metadata[:activation_code], - re_namespaced_gem.metadata[:memoization_method], - re_namespaced_gem.gem_name == "memo_wise" ? GITHUB_MAIN_BENCHMARK_NAME : re_namespaced_gem.gem_name, - ) if re_namespaced_gem.required? - }.concat( - [ - BenchmarkGem.new(MemoWise, "prepend MemoWise", :memo_wise, LOCAL_BENCHMARK_NAME), - (BenchmarkGem.new(DDMemoize, "DDMemoize.activate(self)", :memoize, "ddmemoize") if defined?(DDMemoize)), - (BenchmarkGem.new(Dry::Core, "include Dry::Core::Memoizable", :memoize, "dry-core") if defined?(Dry::Core)), - (BenchmarkGem.new(Memery, "include Memery", :memoize, "memery") if defined?(Memery)), - (BenchmarkGem.new(Memoized, "include Memoized", :memoize, "memoized") if defined?(Memoized)), - (BenchmarkGem.new(Memoizer, "include Memoizer", :memoize, "memoizer") if defined?(Memoizer)) - ] - )).compact.shuffle +benchmarked_gems = re_namespaced_gems.select(&:required?).map do |re_namespaced_gem| + BenchmarkGem.new( + re_namespaced_gem.as_klass, + re_namespaced_gem.metadata[:activation_code], + re_namespaced_gem.metadata[:memoization_method], + re_namespaced_gem.gem_name == "memo_wise" ? GITHUB_MAIN_BENCHMARK_NAME : re_namespaced_gem.gem_name, + ) +end +benchmarked_gems.push( + BenchmarkGem.new(MemoWise, "prepend MemoWise", :memo_wise, LOCAL_BENCHMARK_NAME), + (BenchmarkGem.new(DDMemoize, "DDMemoize.activate(self)", :memoize, "ddmemoize") if defined?(DDMemoize)), + (BenchmarkGem.new(Dry::Core, "include Dry::Core::Memoizable", :memoize, "dry-core") if defined?(Dry::Core)), + (BenchmarkGem.new(Memery, "include Memery", :memoize, "memery") if defined?(Memery)), + (BenchmarkGem.new(Memoized, "include Memoized", :memoize, "memoized") if defined?(Memoized)), + (BenchmarkGem.new(Memoizer, "include Memoizer", :memoize, "memoizer") if defined?(Memoizer)) +) +BENCHMARK_GEMS = benchmarked_gems.compact.shuffle puts "\nWill BENCHMARK_GEMS:\n\t#{BENCHMARK_GEMS.map(&:benchmark_name).join("\n\t")}\n"