Skip to content
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

x/playground: detect and run Benchmark functions #38731

bcmills opened this issue Apr 28, 2020 · 0 comments

x/playground: detect and run Benchmark functions #38731

bcmills opened this issue Apr 28, 2020 · 0 comments


Copy link

@bcmills bcmills commented Apr 28, 2020

What did you do?

Wrote a Playground source file containing a Benchmark function, for which I wanted to see the allocations per operation (a number that does not depend in any way on the absolute running time of the program):

package main

import (

func BenchmarkAlloc(b *testing.B) {

	for n := b.N; n > 0; n-- {
		x := new(int)

What did you expect to see?

Output similar to go test -bench .:

goos: linux
goarch: amd64
BenchmarkAlloc-6        1000000000               0.285 ns/op           0 B/op          0 allocs/op
ok     0.346s

What did you see instead?

runtime.main_main·f: function main is undeclared in the main package

Go build failed.


CC @andybons @dmitshur @toothrot @cagedmantis

See previously #24311, #6511, #32403.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant