@@ -14,39 +14,39 @@ runtime/pprof
14
14
- 首先在beego.Run函数中根据变量是否自动加载性能包
15
15
``` Go
16
16
17
- if PprofOn {
18
- BeeApp .RegisterController (` /debug/pprof` , &ProfController{})
19
- BeeApp .RegisterController (` /debug/pprof/:pp([\w]+)` , &ProfController{})
20
- }
17
+ if PprofOn {
18
+ BeeApp .RegisterController (` /debug/pprof` , &ProfController{})
19
+ BeeApp .RegisterController (` /debug/pprof/:pp([\w]+)` , &ProfController{})
20
+ }
21
21
```
22
22
- 设计ProfConterller
23
23
``` Go
24
24
25
- package beego
26
-
27
- import (
28
- " net/http/pprof"
29
- )
30
-
31
- type ProfController struct {
32
- Controller
33
- }
34
-
35
- func (this *ProfController ) Get () {
36
- switch this.Ctx .Params [" :pp" ] {
37
- default :
38
- pprof.Index (this.Ctx .ResponseWriter , this.Ctx .Request )
39
- case " " :
40
- pprof.Index (this.Ctx .ResponseWriter , this.Ctx .Request )
41
- case " cmdline" :
42
- pprof.Cmdline (this.Ctx .ResponseWriter , this.Ctx .Request )
43
- case " profile" :
44
- pprof.Profile (this.Ctx .ResponseWriter , this.Ctx .Request )
45
- case " symbol" :
46
- pprof.Symbol (this.Ctx .ResponseWriter , this.Ctx .Request )
47
- }
48
- this.Ctx .ResponseWriter .WriteHeader (200 )
25
+ package beego
26
+
27
+ import (
28
+ " net/http/pprof"
29
+ )
30
+
31
+ type ProfController struct {
32
+ Controller
33
+ }
34
+
35
+ func (this *ProfController ) Get () {
36
+ switch this.Ctx .Params [" :pp" ] {
37
+ default :
38
+ pprof.Index (this.Ctx .ResponseWriter , this.Ctx .Request )
39
+ case " " :
40
+ pprof.Index (this.Ctx .ResponseWriter , this.Ctx .Request )
41
+ case " cmdline" :
42
+ pprof.Cmdline (this.Ctx .ResponseWriter , this.Ctx .Request )
43
+ case " profile" :
44
+ pprof.Profile (this.Ctx .ResponseWriter , this.Ctx .Request )
45
+ case " symbol" :
46
+ pprof.Symbol (this.Ctx .ResponseWriter , this.Ctx .Request )
49
47
}
48
+ this.Ctx .ResponseWriter .WriteHeader (200 )
49
+ }
50
50
51
51
```
52
52
## 使用入门
0 commit comments