writestring

package
v0.0.0-...-b91b1e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

README

Elementary writing of a string to a buffer

The target is of type *buffer.Bytes and the string is simply written to it. An elementary case is considered. Any formatting or processing makes this benchmark irrelevant. This module is using methods writing a string without conversion.

  • fmt.Fprint
  • WriteString() method of buffer package
  • io.WriteString()

As fmt offers more possibilities, it takes about 3x the cost as others.

src>go test -bench=. ./writestring

Results

go version go1.12.6 windows/amd64
pkg: github.com/iWdGo/GoCompilerEfficiency/src/writestring
BenchmarkFmtWriteString-4        1000000              1885 ns/op
BenchmarkIoWriteString-4         2000000               694 ns/op
BenchmarkBufferWriteString-4     3000000               447 ns/op
PASS

Documentation

Overview

writestring benchmarks the elementary io.WriteString and package fmt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL