内容简介:sinatra 和 grape都是ruby 的api框架。性能上: sinatra大约是 grape的2倍。高判立下。$ ab -n 1000 -c 100 http://localhost:4567/hi?name=jim
sinatra 和 grape都是 ruby 的api框架。
性能上: sinatra大约是 grape的2倍。高判立下。
sinatra代码
require 'sinatra'
get '/hi' do
"Put this in your pipe & smoke it!, name: #{params[:name]}"
end
$ ab -n 1000 -c 100 http://localhost:4567/hi?name=jim
Requests per second: 1629.18 [#/sec] (mean)
grape代码
require 'sinatra'
require 'grape'
class API < Grape::API
format :json
params do
requires :name, type: String
optional :number, type: String, regexp: /abc.*/
optional :page, type: Integer
end
get :hello do
{
hello: "hello #{params[:name]}, #{params[:number]}"
}
end
get :hi do
{
hi: 'good day!'
}
end
end
run API
$ ab -n 1000 -c 100 http://localhost:9292/hello.json?name=siwei
Requests per second: 647.96 [#/sec] (mean)
$ ab -n 1000 -c 100 http://localhost:9292/hi.json
Requests per second: 813.11 [#/sec] (mean)
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Metasploit渗透测试魔鬼训练营
诸葛建伟、陈力波、田繁、孙松柏、等 / 机械工业出版社 / 2013-9-1 / 89.00元
首本中文原创Metasploit渗透测试著作,国内信息安全领域布道者和资深Metasploit渗透测试专家领衔撰写,极具权威性。以实践为导向,既详细讲解了Metasploit渗透测试的技术、流程、方法和技巧,又深刻阐释了渗透测试平台背后蕴含的思想。 本书是Metasploit渗透测试领域难得的经典佳作,由国内信息安全领域的资深Metasploit渗透测试专家领衔撰写。内容系统、广泛、有深度,......一起来看看 《Metasploit渗透测试魔鬼训练营》 这本书的介绍吧!