Skip to content

Commit 46ab658

Browse files
committed
Add simple benchmark. [ci skip]
1 parent 96b516e commit 46ab658

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

benchmark/simple.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2+
require 'grape'
3+
require 'benchmark'
4+
5+
class API < Grape::API
6+
prefix :api
7+
version 'v1', using: :path
8+
get '/' do
9+
'hello'
10+
end
11+
end
12+
13+
options = {
14+
method: 'GET'
15+
}
16+
17+
env = Rack::MockRequest.env_for('/api/v1', options)
18+
19+
10.times do |i|
20+
env["HTTP_HEADER#{i}"] = '123'
21+
end
22+
23+
iters = 5000
24+
25+
Benchmark.bm do |bm|
26+
bm.report('simple') do
27+
iters.times do
28+
API.call env
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)