File: simple.rb

package info (click to toggle)
ruby-grape 0.16.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,736 kB
  • ctags: 1,175
  • sloc: ruby: 17,103; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'grape'
require 'benchmark/ips'

class API < Grape::API
  prefix :api
  version 'v1', using: :path
  get '/' do
    'hello'
  end
end

options = {
  method: 'GET'
}

env = Rack::MockRequest.env_for('/api/v1', options)

10.times do |i|
  env["HTTP_HEADER#{i}"] = '123'
end

Benchmark.ips do |ips|
  ips.report('simple') do
    API.call env
  end
end