Update progress output format with compact file counts
New format: Progress [5.7k/610k] 6.7 GB/44 GB (15.4%), 106 MB/sec, 500 files/sec, running for 1m30s, ETA: 5m49s - Compact file counts with k/M suffixes in brackets - Bytes processed/total with percentage - Both byte rate and file rate - Elapsed time shown as "running for X"
This commit is contained in:
parent
8a8651c690
commit
40fff09594
@ -502,22 +502,26 @@ func (s *Scanner) processPhase(ctx context.Context, filesToProcess []*FileToProc
|
|||||||
if time.Since(lastStatusTime) >= statusInterval {
|
if time.Since(lastStatusTime) >= statusInterval {
|
||||||
elapsed := time.Since(startTime)
|
elapsed := time.Since(startTime)
|
||||||
pct := float64(bytesProcessed) / float64(totalBytes) * 100
|
pct := float64(bytesProcessed) / float64(totalBytes) * 100
|
||||||
rate := float64(bytesProcessed) / elapsed.Seconds()
|
byteRate := float64(bytesProcessed) / elapsed.Seconds()
|
||||||
|
fileRate := float64(filesProcessed) / elapsed.Seconds()
|
||||||
|
|
||||||
// Calculate ETA based on bytes (more accurate than files)
|
// Calculate ETA based on bytes (more accurate than files)
|
||||||
remainingBytes := totalBytes - bytesProcessed
|
remainingBytes := totalBytes - bytesProcessed
|
||||||
var eta time.Duration
|
var eta time.Duration
|
||||||
if rate > 0 {
|
if byteRate > 0 {
|
||||||
eta = time.Duration(float64(remainingBytes)/rate) * time.Second
|
eta = time.Duration(float64(remainingBytes)/byteRate) * time.Second
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Progress: %s/%s (%s/%s files, %.1f%%), %s/sec",
|
// Format: Progress [5.7k/610k] 6.7 GB/44 GB (15.4%), 106MB/sec, 500 files/sec, running for 1m30s, ETA: 5m49s
|
||||||
|
fmt.Printf("Progress [%s/%s] %s/%s (%.1f%%), %s/sec, %.0f files/sec, running for %s",
|
||||||
|
formatCompact(filesProcessed),
|
||||||
|
formatCompact(totalFiles),
|
||||||
humanize.Bytes(uint64(bytesProcessed)),
|
humanize.Bytes(uint64(bytesProcessed)),
|
||||||
humanize.Bytes(uint64(totalBytes)),
|
humanize.Bytes(uint64(totalBytes)),
|
||||||
formatNumber(filesProcessed),
|
|
||||||
formatNumber(totalFiles),
|
|
||||||
pct,
|
pct,
|
||||||
humanize.Bytes(uint64(rate)))
|
humanize.Bytes(uint64(byteRate)),
|
||||||
|
fileRate,
|
||||||
|
elapsed.Round(time.Second))
|
||||||
if eta > 0 {
|
if eta > 0 {
|
||||||
fmt.Printf(", ETA: %s", eta.Round(time.Second))
|
fmt.Printf(", ETA: %s", eta.Round(time.Second))
|
||||||
}
|
}
|
||||||
@ -898,3 +902,17 @@ func formatNumber(n int) string {
|
|||||||
}
|
}
|
||||||
return humanize.Comma(int64(n))
|
return humanize.Comma(int64(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// formatCompact formats a number compactly with k/M suffixes (e.g., 5.7k, 1.2M)
|
||||||
|
func formatCompact(n int) string {
|
||||||
|
if n < 1000 {
|
||||||
|
return fmt.Sprintf("%d", n)
|
||||||
|
}
|
||||||
|
if n < 10000 {
|
||||||
|
return fmt.Sprintf("%.1fk", float64(n)/1000)
|
||||||
|
}
|
||||||
|
if n < 1000000 {
|
||||||
|
return fmt.Sprintf("%.0fk", float64(n)/1000)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%.1fM", float64(n)/1000000)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user