Go Benchmark
Printing
Compare fmt's Print, Printf, and Println variants, with and without a target writer.
The Go fmt package provides several functions for printing output. This benchmark compares Print, Println, and Printf (which write to stdout) against their Fprint, Fprintln, and Fprintf counterparts (which write to an io.Writer, here io.Discard). The Fprint variants avoid the overhead of going through os.Stdout, making them noticeably faster.
Uses fmt.Fprintln to write a string followed by a newline directly to io.Discard, bypassing stdout entirely.
Fprint #
Uses fmt.Fprint to write a string directly to io.Discard, bypassing stdout entirely.
Fprintf #
Uses fmt.Fprintf with a %s verb to write a formatted string directly to io.Discard, bypassing stdout entirely.
Println #
Uses fmt.Println to write a string followed by a newline to stdout (redirected to /dev/null).
Printf #
Uses fmt.Printf with a %s verb to write a formatted string to stdout (redirected to /dev/null).
Uses fmt.Print to write a string to stdout (redirected to /dev/null).
Contributors