mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
gf/beego性能测试
This commit is contained in:
@ -91,12 +91,17 @@ func (s *Server) setHookHandler(pattern string, hook string, item *HandlerItem)
|
||||
// 事件回调 - 检索动态路由规则
|
||||
// 并按照指定hook回调函数的优先级及注册顺序进行调用
|
||||
func (s *Server) callHookHandler(r *Request, hook string) {
|
||||
|
||||
// 缓存清空时是直接修改属性,因此必须使用互斥锁
|
||||
s.hhcmu.RLock()
|
||||
defer s.hhcmu.RUnlock()
|
||||
|
||||
var hookItems []*hookCacheItem
|
||||
cacheKey := s.handlerHookKey(r.GetHost(), r.Method, r.URL.Path, hook)
|
||||
|
||||
return
|
||||
|
||||
|
||||
if v := s.hooksCache.Get(cacheKey); v == nil {
|
||||
hookItems = s.searchHookHandler(r, hook)
|
||||
if hookItems != nil {
|
||||
|
||||
14
geg/net/ghttp/performance/beego/dynamic.go
Normal file
14
geg/net/ghttp/performance/beego/dynamic.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
)
|
||||
|
||||
func main() {
|
||||
beego.Get("/:name",func(ctx *context.Context){
|
||||
ctx.Output.Body([]byte(ctx.Input.Param(":name")))
|
||||
})
|
||||
beego.BeeLogger.SetLevel(0)
|
||||
beego.Run(":8199")
|
||||
}
|
||||
14
geg/net/ghttp/performance/beego/static.go
Normal file
14
geg/net/ghttp/performance/beego/static.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
)
|
||||
|
||||
func main() {
|
||||
beego.Get("/",func(ctx *context.Context){
|
||||
ctx.Output.Body([]byte("哈喽世界!"))
|
||||
})
|
||||
beego.BeeLogger.SetLevel(0)
|
||||
beego.Run(":8199")
|
||||
}
|
||||
@ -19,8 +19,11 @@ func main() {
|
||||
for i := 0; i < clientMax; i++ {
|
||||
wg.Add(1)
|
||||
go func(clientId int) {
|
||||
for j := 0; j < requestMax; j++ {
|
||||
if c, e := ghttp.Get("http://127.0.0.1/"); e == nil {
|
||||
url := "http://127.0.0.1:8199/"
|
||||
for i := 0; i < requestMax; i++ {
|
||||
//url = fmt.Sprintf("http://127.0.0.1:8199/%d_%d", clientId, i)
|
||||
if c, e := ghttp.Get(url); e == nil {
|
||||
//fmt.Println(string(c.ReadAll()))
|
||||
c.Close()
|
||||
successNum.Add(1)
|
||||
} else {
|
||||
|
||||
@ -7,8 +7,8 @@ import (
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.BindHandler("/dynamic/:name", func(r *ghttp.Request){
|
||||
r.Response.Writeln(r.Get("name"))
|
||||
s.BindHandler("/:name", func(r *ghttp.Request){
|
||||
r.Response.Write(r.Get("name"))
|
||||
})
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
|
||||
@ -8,8 +8,9 @@ import (
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.BindHandler("/", func(r *ghttp.Request){
|
||||
r.Response.Writeln("哈喽世界!")
|
||||
r.Response.Write("哈喽世界!")
|
||||
})
|
||||
s.EnablePprof()
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user