Fix section "Getting started" in 14.6.md
This commit is contained in:
14
en/14.6.md
14
en/14.6.md
@@ -12,14 +12,14 @@ In fact, `net/http/pprof` simply exposes runtime profiling data from the `runtim
|
||||
|
||||
The Beego framework currently supports pprof, however it is not not turned on by default. If you need to test the performance of your application, (for instance by viewing the execution goroutine such information, in fact, Go's default package "net/http/pprof" already has this feature, and if Go manner in accordance with the default Web, you can use the default, but because beego repackaged ServHTTP function, so if you can not open the default includes this feature, so the need for internal reform beego support pprof.
|
||||
|
||||
- First in beego.Run function automatically according to whether the variable load performance pack
|
||||
- First in our `beego.Run` function, we choose whether or not to automatically load the performance pack according to our configuration variable (in this case, PprofOn):
|
||||
|
||||
if PprofOn {
|
||||
BeeApp.RegisterController(`/debug/pprof`, &ProfController{})
|
||||
BeeApp.RegisterController(`/debug/pprof/:pp([\w]+)`, &ProfController{})
|
||||
}
|
||||
|
||||
- Design ProfConterller
|
||||
- Designing `ProfController`
|
||||
|
||||
package beego
|
||||
|
||||
@@ -50,27 +50,27 @@ The Beego framework currently supports pprof, however it is not not turned on by
|
||||
|
||||
## Getting started
|
||||
|
||||
Through the above design, you can use the following code to open pprof:
|
||||
From the above, we can see that enabling pprof is as simple as setting the `PprofOn` configuration variable to `true`:
|
||||
|
||||
beego.PprofOn = true
|
||||
|
||||
Then you can open in a browser the following URL to see the following interface:
|
||||
You can then open the following URL in your browser to see the following interface:
|
||||
|
||||

|
||||
|
||||
Figure 14.7 current system goroutine, heap, thread information
|
||||
|
||||
Click goroutine we can see a lot of detailed information:
|
||||
By clicking on a goroutine, we can see a lot of detailed information:
|
||||
|
||||

|
||||
|
||||
Figure 14.8 shows the current goroutine details
|
||||
|
||||
We can also get more details from the command line information
|
||||
Of course, we can also get more details from the command line:
|
||||
|
||||
go tool pprof http://localhost:8080/debug/pprof/profile
|
||||
|
||||
This time the program will enter the profile collection time of 30 seconds, during which time desperately to refresh the page on the browser, try to make cpu usage performance data.
|
||||
This time, the program will begin profiling the application for a period of 30 seconds, during which time it will repeatedly refresh the page in the browser in an attempt to gather CPU usage and performance data.
|
||||
|
||||
(pprof) top10
|
||||
|
||||
|
||||
Reference in New Issue
Block a user