1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-02 09:21:54 +02:00

chore: use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (#789)

This commit is contained in:
guangwu 2023-10-05 08:26:07 +08:00 committed by GitHub
parent 7f6c45fde6
commit abd6a895f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -114,21 +114,21 @@ func (p *Profiler) Print(label string) {
timer, found := p.timers[label]
if found {
fmt.Fprintln(writer, fmt.Sprintf("Time: %s", timer.end.Sub(timer.start)))
fmt.Fprintf(writer, "Time: %s\n", timer.end.Sub(timer.start))
}
stats, found := p.allocs[label]
if found {
fmt.Fprintln(writer, fmt.Sprintf("Alloc: %s", byteCountDecimal(stats.Alloc)))
fmt.Fprintln(writer, fmt.Sprintf("Frees: %s", byteCountDecimal(stats.Frees)))
fmt.Fprintln(writer, fmt.Sprintf("Total Alloc: %s", byteCountDecimal(stats.TotalAlloc)))
fmt.Fprintln(writer, fmt.Sprintf("Heap Alloc: %s", byteCountDecimal(stats.HeapAlloc)))
fmt.Fprintln(writer, fmt.Sprintf("Heap Sys: %s", byteCountDecimal(stats.HeapSys)))
fmt.Fprintln(writer, fmt.Sprintf("Heap Idle: %s", byteCountDecimal(stats.HeapIdle)))
fmt.Fprintln(writer, fmt.Sprintf("Heap In Use: %s", byteCountDecimal(stats.HeapInuse)))
fmt.Fprintln(writer, fmt.Sprintf("Heap Released: %s", byteCountDecimal(stats.HeapReleased)))
fmt.Fprintln(writer, fmt.Sprintf("Heap Objects: %d", stats.HeapObjects))
fmt.Fprintf(writer, "Alloc: %s\n", byteCountDecimal(stats.Alloc))
fmt.Fprintf(writer, "Frees: %s\n", byteCountDecimal(stats.Frees))
fmt.Fprintf(writer, "Total Alloc: %s\n", byteCountDecimal(stats.TotalAlloc))
fmt.Fprintf(writer, "Heap Alloc: %s\n", byteCountDecimal(stats.HeapAlloc))
fmt.Fprintf(writer, "Heap Sys: %s\n", byteCountDecimal(stats.HeapSys))
fmt.Fprintf(writer, "Heap Idle: %s\n", byteCountDecimal(stats.HeapIdle))
fmt.Fprintf(writer, "Heap In Use: %s\n", byteCountDecimal(stats.HeapInuse))
fmt.Fprintf(writer, "Heap Released: %s\n", byteCountDecimal(stats.HeapReleased))
fmt.Fprintf(writer, "Heap Objects: %d\n", stats.HeapObjects)
}
//cpu, found := p.cpus[label]
@ -138,7 +138,7 @@ func (p *Profiler) Print(label string) {
//}
if writer.Len() > 0 {
fmt.Println(fmt.Sprintf("%s:", label))
fmt.Printf("%s:\n", label)
fmt.Println("-----")
fmt.Println(writer.String())
}
@ -440,7 +440,7 @@ func execQuery(ctx context.Context, engine *ferret.Instance, opts []runtime.Opti
prof.PrintAll()
if out != nil {
fmt.Println(fmt.Sprintf("Output size: %s", byteCountDecimal(uint64(len(out)))))
fmt.Printf("Output size: %s\n", byteCountDecimal(uint64(len(out))))
fmt.Println("")
}
}

View File

@ -27,7 +27,7 @@ func main() {
}
for _, topic := range topics {
fmt.Println(fmt.Sprintf("%s: %s %s", topic.Name, topic.Description, topic.URL))
fmt.Printf("%s: %s %s\n", topic.Name, topic.Description, topic.URL)
}
}