Skip to content
  • Aaron Patterson's avatar
    a3eb5e5c
    Don't call `Warning.warn` unless the category is enabled (#10981) · a3eb5e5c
    Aaron Patterson authored
    Don't call `Warning.warn` unless the category is enabled
    
    The warning category should be enabled if we want to call
    `Warning.warn`.
    
    This commit speeds up the following benchmark:
    
    ```ruby
    eval "def test; " +
      1000.times.map { "'  '.chomp!" }.join(";") + "; end"
    
    def run_benchmark count
      i = 0
      while i < count
        start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
        yield
        ms = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
        puts "itr ##{i}: #{(ms * 1000).to_i}ms"
        i += 1
      end
    end
    
    run_benchmark(25) do
      250.times do
        test
      end
    end
    ```
    
    On `master` this runs at about 92ms per iteration. With this patch, it
    is 7ms per iteration.
    
    [Bug #20573]
    a3eb5e5c
    Don't call `Warning.warn` unless the category is enabled (#10981)
    Aaron Patterson authored
    Don't call `Warning.warn` unless the category is enabled
    
    The warning category should be enabled if we want to call
    `Warning.warn`.
    
    This commit speeds up the following benchmark:
    
    ```ruby
    eval "def test; " +
      1000.times.map { "'  '.chomp!" }.join(";") + "; end"
    
    def run_benchmark count
      i = 0
      while i < count
        start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
        yield
        ms = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
        puts "itr ##{i}: #{(ms * 1000).to_i}ms"
        i += 1
      end
    end
    
    run_benchmark(25) do
      250.times do
        test
      end
    end
    ```
    
    On `master` this runs at about 92ms per iteration. With this patch, it
    is 7ms per iteration.
    
    [Bug #20573]
Loading