8000 Benchmark tool command line issues: "go test -bench ." works but "go test -bench=." doesn't · Issue #73593 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Benchmark tool command line issues: "go test -bench ." works but "go test -bench=." doesn't #73593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RickSanch3z opened this issue May 3, 2025 · 2 comments
Labels
ToolProposal Issues describing a requested change to a Go tool or command-line program.

Comments

@RickSanch3z
Copy link

Go version

go version go1.24.2 windows/amd64

Output of go env in your module/workspace:

set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\u1\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\u1\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\USER_N~1\AppData\Local\Temp\go-build3576284606=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=E:\go\ch1\echo_test\go.mod
set GOMODCACHE=C:\Users\u1\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\u1\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\u1\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.2
set GOWORK=
set PKG_CONFIG=pkg-config

What did you do?

Tried to run "go test" benchmark tool.
Here's the code:

package echo_test

import (
	"strings"
	"testing"
)

var (
	args_slice = []string{"a0", "a1", "a2", "a3", "a4"}
	sep string = ""
	s string = ""
)

func BenchmarkEchoStandardLoop(b *testing.B) {
	s = ""
	sep = ""
	for i := 0; i < b.N; i++ {
		for j := 0; j < len(args_slice); j++ {
			s += sep + args_slice[j]
			sep = " "
		}
	}
}

func BenchmarkEchoRangeLoop(b *testing.B) {
	s = ""
	sep = ""
	for i := 0; i < b.N; i++ {
		for _, arg := range args_slice {
			s += sep + arg
			sep = " "
		}
	}
}

func BenchmarkEchoStringsJoin(b *testing.B) {
	s = ""
	sep = ""
	for i := 0; i < b.N; i++ {
		s = strings.Join(args_slice, " ")
	}
}

What did you see happen?

With "go test -bench=." it printed:

ok echo_test 0.291s [no tests to run]

But with "go test -bench ." it launched the benchmark:

...
BenchmarkEchoStandardLoop-8 16408 109289 ns/op
BenchmarkEchoRangeLoop-8 17733 127269 ns/op
BenchmarkEchoStringsJoin-8 13529373 85.89 ns/op

What did you expect to see?

Expected to see the result of the benchmark.

@RickSanch3z RickSanch3z changed the title Benchmark tool command line issues: "go test -bench ." works but "go test -bench=." Benchmark tool command line issues: "go test -bench ." works but "go test -bench=." doesn't May 3, 2025
@gabyhelp gabyhelp added the ToolProposal Issues describing a requested change to a Go tool or command-line program. label May 3, 2025
@seankhliao
Copy link
Member

This is a powershell bug where it passes -bench=. to programs as 2 args: -bench= and ..
PowerShell/PowerShell#6291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ToolProposal Issues describing a requested change to a Go tool or command-line program.
Projects
None yet
Development

No branches or pull requests

3 participants
0