Skip to content

Conversation

@jkowens
Copy link
Contributor

@jkowens jkowens commented Jan 2, 2018

This is an attempt to resolve #1672.

Benchmark script:

require 'grape'
require 'benchmark/ips'

Benchmark.ips do |ips|
  ips.report('class_load') do
    class API < Grape::API
      prefix :api
      version 'v1', using: :path
      get '/' do
        'hello'
      end
    end
  end
end

Before:

Warming up --------------------------------------
          class_load   590.000  i/100ms
Calculating -------------------------------------
          class_load      5.589k (±10.3%) i/s -     27.730k in   5.029428s

After:

Warming up --------------------------------------
          class_load   860.000  i/100ms
Calculating -------------------------------------
          class_load      8.761k (±13.6%) i/s -     43.000k in   5.035511s

@grape-bot
Copy link

grape-bot commented Jan 2, 2018

1 Warning
⚠️ There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code.

Generated by 🚫 danger

@dblock
Copy link
Member

dblock commented Jan 3, 2018

I think this code is an MRI 1.8 artifact, since 0e0a94f was fixing some issue there and we haven't touched it for 5 years, so LGTM.

@dblock
Copy link
Member

dblock commented Jan 3, 2018

I think this deserves a CHANGELOG entry. Maybe something like "Improved startup performance during API method generation"?

@jkowens
Copy link
Contributor Author

jkowens commented Jan 4, 2018

I've added that changelog entry, thanks!

@dblock dblock merged commit 74e21ab into ruby-grape:master Jan 4, 2018
@dblock
Copy link
Member

dblock commented Jan 4, 2018

Merged, thank you.

@jkowens jkowens deleted the fix-1672 branch January 16, 2018 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grape is slow to initialize

3 participants