Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
8b374d7f
Commit
8b374d7f
authored
May 20, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego: add benchmark
parent
fa323414
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletion
+43
-1
router_test.go
router_test.go
+43
-1
No files found.
router_test.go
View file @
8b374d7f
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"testing"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/context"
)
)
...
@@ -273,3 +272,46 @@ func TestRouterHandler(t *testing.T) {
...
@@ -273,3 +272,46 @@ func TestRouterHandler(t *testing.T) {
t
.
Errorf
(
"TestRouterHandler can't run"
)
t
.
Errorf
(
"TestRouterHandler can't run"
)
}
}
}
}
//
// Benchmarks NewApp:
//
func
beegoFilterFunc
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"hello"
)
}
type
AdminController
struct
{
Controller
}
func
(
a
*
AdminController
)
Get
()
{
a
.
Ctx
.
WriteString
(
"hello"
)
}
func
BenchmarkFunc
(
b
*
testing
.
B
)
{
mux
:=
NewControllerRegistor
()
mux
.
Get
(
"/action"
,
beegoFilterFunc
)
rw
,
r
:=
testRequest
(
"GET"
,
"/action"
)
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
mux
.
ServeHTTP
(
rw
,
r
)
}
}
func
BenchmarkController
(
b
*
testing
.
B
)
{
mux
:=
NewControllerRegistor
()
mux
.
Add
(
"/action"
,
&
AdminController
{})
rw
,
r
:=
testRequest
(
"GET"
,
"/action"
)
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
mux
.
ServeHTTP
(
rw
,
r
)
}
}
func
testRequest
(
method
,
path
string
)
(
*
httptest
.
ResponseRecorder
,
*
http
.
Request
)
{
request
,
_
:=
http
.
NewRequest
(
method
,
path
,
nil
)
recorder
:=
httptest
.
NewRecorder
()
return
recorder
,
request
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment