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

Delta Between Two Patch Sets: src/pkg/testing/benchmark.go

Issue 7027046: code review 7027046: testing: introduce (*B).EnableMallocReport() (Closed)
Left Patch Set: diff -r 28ee66c9003f https://code.google.com/p/go Created 11 years, 2 months ago
Right Patch Set: diff -r a55bd9f21507 https://code.google.com/p/go/ Created 11 years, 2 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/exp/html/token_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 b.duration = 0 86 b.duration = 0
87 b.netAllocs = 0 87 b.netAllocs = 0
88 b.netBytes = 0 88 b.netBytes = 0
89 } 89 }
90 90
91 // SetBytes records the number of bytes processed in a single operation. 91 // SetBytes records the number of bytes processed in a single operation.
92 // If this is called, the benchmark will report ns/op and MB/s. 92 // If this is called, the benchmark will report ns/op and MB/s.
93 func (b *B) SetBytes(n int64) { b.bytes = n } 93 func (b *B) SetBytes(n int64) { b.bytes = n }
94 94
95 // ReportAllocs enables malloc statistics for this benchmark, just 95 // ReportAllocs enables malloc statistics for this benchmark.
96 // like what you get when you pass -test.benchmem. 96 // It is equivalent to setting -test.benchmem, but it only affects the
bradfitz 2013/01/12 17:08:52 avoid the word "you". as far as I know, we don't
97 // benchmark function that calls ReportAllocs.
97 func (b *B) ReportAllocs() { 98 func (b *B) ReportAllocs() {
98 b.showAllocResult = true 99 b.showAllocResult = true
99 } 100 }
100 101
101 func (b *B) nsPerOp() int64 { 102 func (b *B) nsPerOp() int64 {
102 if b.N <= 0 { 103 if b.N <= 0 {
103 return 0 104 return 0
104 } 105 }
105 return b.duration.Nanoseconds() / int64(b.N) 106 return b.duration.Nanoseconds() / int64(b.N)
106 } 107 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // custom benchmarks that do not use the "go test" command. 344 // custom benchmarks that do not use the "go test" command.
344 func Benchmark(f func(b *B)) BenchmarkResult { 345 func Benchmark(f func(b *B)) BenchmarkResult {
345 b := &B{ 346 b := &B{
346 common: common{ 347 common: common{
347 signal: make(chan interface{}), 348 signal: make(chan interface{}),
348 }, 349 },
349 benchmark: InternalBenchmark{"", f}, 350 benchmark: InternalBenchmark{"", f},
350 } 351 }
351 return b.run() 352 return b.run()
352 } 353 }
LEFTRIGHT

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