mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-04 00:31:10 +08:00
25w12d
This commit is contained in:
parent
93dbb6d31d
commit
a26eac1097
3 changed files with 18 additions and 5 deletions
|
|
@ -47,7 +47,11 @@ func Middleware() gin.HandlerFunc {
|
|||
// 记录阶段耗时
|
||||
func Record(c *gin.Context, name string) {
|
||||
if val, exists := c.Get("timing"); exists {
|
||||
td := val.(*timingData)
|
||||
//td := val.(*timingData)
|
||||
td, ok := val.(*timingData)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if td.count < len(td.phases) {
|
||||
td.phases[td.count].name = name
|
||||
td.phases[td.count].dur = time.Since(td.start) // 直接记录当前时间
|
||||
|
|
@ -62,7 +66,11 @@ func Get(c *gin.Context) (total time.Duration, phases []struct {
|
|||
Dur time.Duration
|
||||
}) {
|
||||
if val, exists := c.Get("timing"); exists {
|
||||
td := val.(*timingData)
|
||||
//td := val.(*timingData)
|
||||
td, ok := val.(*timingData)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for i := 0; i < td.count; i++ {
|
||||
phases = append(phases, struct {
|
||||
Name string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue