Fetch the repository succeeded.
package main
import (
"fmt"
"os"
"sync"
"time"
)
var (
profLock sync.Mutex
profSectionStartTime time.Time
thingMaxTime map[string]time.Duration
thingMinTime map[string]time.Duration
thingTimes map[string]time.Duration
thingCounts map[string]int
)
func recordThingTime(thing string, d time.Duration) {
profLock.Lock()
now := time.Now()
if now.Sub(profSectionStartTime) >= time.Second {
// start new profile section
dumpThingProfile()
profSectionStartTime = now
thingTimes = map[string]time.Duration{}
thingCounts = map[string]int{}
thingMinTime = map[string]time.Duration{}
thingMaxTime = map[string]time.Duration{}
}
thingCounts[thing] += 1
thingTimes[thing] += d
if oldMaxTime, ok := thingMaxTime[thing]; !ok || oldMaxTime < d {
thingMaxTime[thing] = d
}
if oldMinTime, ok := thingMaxTime[thing]; !ok || oldMinTime > d {
thingMinTime[thing] = d
}
profLock.Unlock()
}
func dumpThingProfile() {
for thing, count := range thingCounts {
totalTime := thingTimes[thing]
fmt.Fprintf(os.Stdout, "> %-32s *%d AVG %s RANGE %s ~ %s\n", thing, count, totalTime/time.Duration(count), thingMinTime[thing], thingMaxTime[thing])
}
fmt.Fprintln(os.Stdout, "===============================================================================")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。