Skip to content

Commit bfe7d5c

Browse files
committed
Add a benchmark for API.compile!
This replicates the slowness in compiling routes via Mustermann for 2000 routes. Part of #1736
1 parent 2bf2c1a commit bfe7d5c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

benchmark/compile_many_routes.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4+
require 'grape'
5+
require 'benchmark/ips'
6+
require 'grape/eager_load'
7+
8+
Grape.eager_load!
9+
10+
class API < Grape::API
11+
prefix :api
12+
version 'v1', using: :path
13+
14+
2000.times do |index|
15+
get "/test#{index}/" do
16+
'hello'
17+
end
18+
end
19+
end
20+
21+
Benchmark.ips do |ips|
22+
ips.report('Compiling 2000 routes') do
23+
API.compile!
24+
end
25+
end

0 commit comments

Comments
 (0)