代码拉取完成,页面将自动刷新
package cache
import (
"fmt"
"sync"
"time"
)
// ScoreBoard 记分牌
type ScoreBoard struct {
m sync.Mutex
Name string `name:"name"` // 名称
Kind Kind `name:"kind"` // 类型
Count int `name:"count"` // 总数
Max time.Duration `name:"max"` // 最大值
Min time.Duration `name:"min"` // 最小值
CrossTime time.Duration `name:"cross_time"` // 总耗时
Speed float64 `name:"speed"` // 速度
}
func (this *ScoreBoard) From(adapter DataAdapter) {
this.Name = adapter.Name()
this.Kind = adapter.Kind()
}
func (this *ScoreBoard) Add(delta int, take time.Duration) {
this.m.Lock()
defer this.m.Unlock()
this.Count = this.Count + delta
this.CrossTime += take
if this.Min == 0 || this.Min > take {
this.Min = take
}
if this.Max == 0 || this.Max < take {
this.Max = take
}
this.Speed = float64(this.Count) / this.CrossTime.Seconds()
}
func (this *ScoreBoard) String() string {
s := fmt.Sprintf("name: %s, kind: %d, total: %d, crosstime: %s, max: %d, min: %d, speed: %f", this.Name, this.Kind, this.Count, this.CrossTime, this.Max, this.Min, this.Speed)
return s
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。