7
Allow entirely opting out of deprecation warnings by ghiculescu · Pull Request #...
source link: https://github.com/rails/rails/pull/42913
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Here is a benchmark:
require "bundler/inline" gemfile(true) do source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem "rails", github: "rails/rails", branch: "main" gem "benchmark-ips" end require "active_support" class MainBranch < ActiveSupport::Deprecation end class WithThisPR < ActiveSupport::Deprecation def initialize(*) super self.silenced = true end end WithThisPR.behavior = :silence MainBranch.behavior = :silence Benchmark.ips do |x| x.report("entirely silenced with this PR") { WithThisPR.warn("foo") } x.report("behavior = :silence on main branch") { MainBranch.warn("foo") } x.compare! end
Warming up --------------------------------------
entirely silenced with this PR
18.693k i/100ms
behavior = :silence on main branch
19.373k i/100ms
Calculating -------------------------------------
entirely silenced with this PR
421.698k (±39.6%) i/s - 1.626M in 5.055943s
behavior = :silence on main branch
174.997k (±10.0%) i/s - 871.785k in 5.028267s
Comparison:
entirely silenced with this PR: 421697.8 i/s
behavior = :silence on main branch: 174996.5 i/s - 2.41x (± 0.00) slower
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK