bench2csv

package module
v0.0.0-...-7b3cb2c Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 6 Imported by: 0

README

go-bench2csv

GoDoc Go

A small CLI to parse the output of go test -bench and output to CSV.

It passes the go test output verbatim on STDERR and the CSV output to STDOUT.

Usage

demo.gif

$ go install github.com/maragudk/go-bench2csv/cmd/bench2csv@latest
$ go test -cpu 1,2,4,8 -bench . | bench2csv >benchmark.csv
goos: darwin
goarch: arm64
pkg: github.com/maragudk/go-bench2csv
BenchmarkProcess/in_parallel_just_for_fun           	    4314	    276820 ns/op
BenchmarkProcess/in_parallel_just_for_fun-2         	    8292	    145504 ns/op
BenchmarkProcess/in_parallel_just_for_fun-4         	   15826	     75832 ns/op
BenchmarkProcess/in_parallel_just_for_fun-8         	   19111	     73122 ns/op
PASS
ok  	github.com/maragudk/go-bench2csv	7.324s

Also works with go test -benchmem:

$ go test -cpu 1,2,4,8 -bench . -benchmem | bench2csv -mem >benchmark.csv
goos: darwin
goarch: arm64
pkg: github.com/maragudk/go-bench2csv
BenchmarkProcess/in_parallel_just_for_fun           	    4106	    292497 ns/op	   53892 B/op	     738 allocs/op
BenchmarkProcess/in_parallel_just_for_fun-2         	    7929	    151227 ns/op	   53897 B/op	     738 allocs/op
BenchmarkProcess/in_parallel_just_for_fun-4         	   15013	     79910 ns/op	   53909 B/op	     738 allocs/op
BenchmarkProcess/in_parallel_just_for_fun-8         	   18214	     66196 ns/op	   53941 B/op	     738 allocs/op
PASS
ok  	github.com/maragudk/go-bench2csv	7.402s

Made in 🇩🇰 by maragu, maker of online Go courses.

Documentation

Index

Constants

View Source
const (
	Name = 1 << iota
	Parallelism
	Operations
	Duration
	Frequency
	BytesPerOp
	AllocsPerOp
	Default = Name | Parallelism | Operations | Duration
	Memory  = BytesPerOp | AllocsPerOp
)

Variables

This section is empty.

Functions

func Process

func Process(in io.Reader, csvOut, errOut io.Writer, format int) error

Process benchmark output from in, write CSV to csvOut, and pipe benchmark output to errOut.

Types

This section is empty.

Directories

Path Synopsis
cmd
bench2csv command

Jump to

Keyboard shortcuts

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