formatDuration 格式化时间显示
(d time.Duration)
| 387 | |
| 388 | // formatDuration 格式化时间显示 |
| 389 | func formatDuration(d time.Duration) string { |
| 390 | if d < time.Millisecond { |
| 391 | return fmt.Sprintf("%.0fµs", float64(d.Nanoseconds())/1000) |
| 392 | } else if d < time.Second { |
| 393 | return fmt.Sprintf("%.0fms", float64(d.Nanoseconds())/1000000) |
| 394 | } else if d < time.Minute { |
| 395 | return fmt.Sprintf("%.2fs", d.Seconds()) |
| 396 | } else { |
| 397 | minutes := int(d.Minutes()) |
| 398 | seconds := int(d.Seconds()) % 60 |
| 399 | return fmt.Sprintf("%dm%ds", minutes, seconds) |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | // sortByRecommendationStars 按推荐星级排序,1星在最上面,5星在最下面 |
| 404 | func (bm *Manager) sortByRecommendationStars(results []*types.DetectionResult) { |