Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1125)

Side by Side Diff: src/pkg/testing/benchmark.go

Issue 3831041: code review 3831041: testing: fix error message on invalid regexp (Closed)
Patch Set: code review 3831041: testing: fix error message on invalid regexp Created 13 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/testing/testing.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package testing 5 package testing
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "os" 10 "os"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // An internal function but exported because it is cross-package; part of the im plementation 168 // An internal function but exported because it is cross-package; part of the im plementation
169 // of gotest. 169 // of gotest.
170 func RunBenchmarks(matchString func(pat, str string) (bool, os.Error), benchmark s []InternalBenchmark) { 170 func RunBenchmarks(matchString func(pat, str string) (bool, os.Error), benchmark s []InternalBenchmark) {
171 // If no flag was specified, don't run benchmarks. 171 // If no flag was specified, don't run benchmarks.
172 if len(*matchBenchmarks) == 0 { 172 if len(*matchBenchmarks) == 0 {
173 return 173 return
174 } 174 }
175 for _, Benchmark := range benchmarks { 175 for _, Benchmark := range benchmarks {
176 matched, err := matchString(*matchBenchmarks, Benchmark.Name) 176 matched, err := matchString(*matchBenchmarks, Benchmark.Name)
177 if err != nil { 177 if err != nil {
178 » » » println("invalid regexp for -benchmarks:", err) 178 » » » println("invalid regexp for -benchmarks:", err.String())
179 os.Exit(1) 179 os.Exit(1)
180 } 180 }
181 if !matched { 181 if !matched {
182 continue 182 continue
183 } 183 }
184 b := &B{benchmark: Benchmark} 184 b := &B{benchmark: Benchmark}
185 r := b.run() 185 r := b.run()
186 fmt.Printf("%s\t%v\n", Benchmark.Name, r) 186 fmt.Printf("%s\t%v\n", Benchmark.Name, r)
187 } 187 }
188 } 188 }
189 189
190 // Benchmark benchmarks a single function. Useful for creating 190 // Benchmark benchmarks a single function. Useful for creating
191 // custom benchmarks that do not use gotest. 191 // custom benchmarks that do not use gotest.
192 func Benchmark(f func(b *B)) BenchmarkResult { 192 func Benchmark(f func(b *B)) BenchmarkResult {
193 b := &B{benchmark: InternalBenchmark{"", f}} 193 b := &B{benchmark: InternalBenchmark{"", f}}
194 return b.run() 194 return b.run()
195 } 195 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/testing/testing.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b