code review 10263043: testing: use -bench flag and fix flags doc link (issue 10263043)

25 views
Skip to first unread message

dpi...@gmail.com

unread,
Jun 14, 2013, 1:58:19 PM6/14/13
to golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reviewers: golang-dev1,

Message:
Hello golan...@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
testing: use -bench flag and fix flags doc link

Please review this at https://codereview.appspot.com/10263043/

Affected files:
M src/pkg/testing/testing.go


Index: src/pkg/testing/testing.go
===================================================================
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -23,10 +23,10 @@
// Functions of the form
// func BenchmarkXxx(*testing.B)
// are considered benchmarks, and are executed by the "go test" command
when
-// the -test.bench flag is provided. Benchmarks are run sequentially.
+// the -bench flag is provided. Benchmarks are run sequentially.
//
// For a description of the testing flags, see
-// http://golang.org/cmd/go/#Description_of_testing_flags.
+// http://golang.org/cmd/go/#hdr-Description_of_testing_flags.
//
// A sample benchmark function looks like this:
// func BenchmarkHello(b *testing.B) {


r...@golang.org

unread,
Jun 14, 2013, 2:10:37 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go
File src/pkg/testing/testing.go (right):

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go#newcode26
src/pkg/testing/testing.go:26: // the -bench flag is provided.
Benchmarks are run sequentially.
the flag is called test.bench.

https://codereview.appspot.com/10263043/

dpi...@gmail.com

unread,
Jun 14, 2013, 3:11:37 PM6/14/13
to golan...@googlegroups.com, r...@golang.org, re...@codereview-hr.appspotmail.com
On 2013/06/14 18:10:37, r wrote:
> the flag is called test.bench.

I think I understand now how flags to `go test` are passed to the
testing binary and that's what would make `go test -test.bench .` work.
If it helps, two things that led to me thinking this snippet was
incorrect were:

* `go test -test.bench` spitting out the `go help` output since I didn't
have a regex
* `go help testflag` listing `-bench` directly

Happy to remove that change if there's nothing salvageable, or add some
more description if it would be helpful. There are example benchmark
functions, perhaps adding an example run of `go test` would be good?

https://codereview.appspot.com/10263043/

r...@golang.org

unread,
Jun 14, 2013, 3:26:46 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
From this package's point of view, the flag is called test.bench. You
can see the declaration. The go test command provides a convenient
shortcut by letting you drop the "test.", but it's a property of go
test, not of this package.

https://codereview.appspot.com/10263043/

k...@xph.us

unread,
Jun 14, 2013, 4:14:32 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, r...@golang.org, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go
File src/pkg/testing/testing.go (right):

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go#newcode26
src/pkg/testing/testing.go:26: // the -bench flag is provided.
Benchmarks are run sequentially.
s/the -bench/its -bench/

https://codereview.appspot.com/10263043/

r...@golang.org

unread,
Jun 14, 2013, 4:20:22 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, k...@xph.us, re...@codereview-hr.appspotmail.com

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go
File src/pkg/testing/testing.go (right):

https://codereview.appspot.com/10263043/diff/5001/src/pkg/testing/testing.go#newcode26
src/pkg/testing/testing.go:26: // the -bench flag is provided.
Benchmarks are run sequentially.
On 2013/06/14 20:14:32, kr wrote:
> s/the -bench/its -bench/

nice solution. +1

https://codereview.appspot.com/10263043/

dpi...@gmail.com

unread,
Jun 14, 2013, 4:24:29 PM6/14/13
to golan...@googlegroups.com, r...@golang.org, k...@xph.us, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com

r...@golang.org

unread,
Jun 14, 2013, 4:25:29 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, k...@xph.us, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com

r...@golang.org

unread,
Jun 14, 2013, 4:28:53 PM6/14/13
to dpi...@gmail.com, golan...@googlegroups.com, k...@xph.us, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reply all
Reply to author
Forward
0 new messages