Skip to content

Speed up override checks

Peter Leitzen requested to merge pl-perf-override-method-defined into master

What does this MR do and why?

Prefer method_defined? over instance_methods.include? (and friends).

Inspired by !103699 (comment 1169110599).

On my local machine I see the following results running hyperfine with bundle exec rake lint:static_verification lint:static_verification_with_database:

Before

$ hyperfine "bundle exec rake lint:static_verification lint:static_verification_with_database"
Benchmark 1: bundle exec rake lint:static_verification lint:static_verification_with_database
  Time (mean ± σ):     14.987 s ±  0.368 s    [User: 13.598 s, System: 0.853 s]
  Range (min … max):   14.588 s … 15.778 s    10 runs

After

$ hyperfine "bundle exec rake lint:static_verification lint:static_verification_with_database"
Benchmark 1: bundle exec rake lint:static_verification lint:static_verification_with_database
  Time (mean ± σ):     14.162 s ±  0.556 s    [User: 12.798 s, System: 0.803 s]
  Range (min … max):   13.324 s … 14.900 s    10 runs

How to set up and validate locally

time bundle exec rake lint:static_verification lint:static_verification_with_database

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports

Loading