N秒平均,更为精确
()
| 26 | const bandwidthTimestampDelim = 2 // N秒平均,更为精确 |
| 27 | |
| 28 | func init() { |
| 29 | if !teaconst.IsMain { |
| 30 | return |
| 31 | } |
| 32 | |
| 33 | events.On(events.EventLoaded, func() { |
| 34 | goman.New(func() { |
| 35 | SharedBandwidthStatManager.Start() |
| 36 | }) |
| 37 | }) |
| 38 | |
| 39 | events.OnClose(func() { |
| 40 | SharedBandwidthStatManager.Cancel() |
| 41 | |
| 42 | err := SharedBandwidthStatManager.Save() |
| 43 | if err != nil { |
| 44 | remotelogs.Error("STAT", "save bandwidth stats failed: "+err.Error()) |
| 45 | } |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | type BandwidthStat struct { |
| 50 | Day string `json:"day"` |