Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
2653b4fb
Commit
2653b4fb
authored
Jun 02, 2011
by
Dmitriy Vyukov
Committed by
Russ Cox
Jun 02, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: fix MB/s computation, documentation
R=rsc CC=golang-dev
https://golang.org/cl/4529100
parent
d1bdff54
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
benchmark.go
src/pkg/testing/benchmark.go
+12
-5
No files found.
src/pkg/testing/benchmark.go
View file @
2653b4fb
...
...
@@ -150,7 +150,7 @@ func (b *B) run() BenchmarkResult {
type
BenchmarkResult
struct
{
N
int
// The number of iterations.
Ns
int64
// The total time taken.
Bytes
int64
//
The total number of bytes processed
.
Bytes
int64
//
Bytes processed in one iteration
.
}
func
(
r
BenchmarkResult
)
NsPerOp
()
int64
{
...
...
@@ -160,13 +160,20 @@ func (r BenchmarkResult) NsPerOp() int64 {
return
r
.
Ns
/
int64
(
r
.
N
)
}
func
(
r
BenchmarkResult
)
mbPerSec
()
float64
{
if
r
.
Bytes
<=
0
||
r
.
Ns
<=
0
||
r
.
N
<=
0
{
return
0
}
return
float64
(
r
.
Bytes
)
*
float64
(
r
.
N
)
/
float64
(
r
.
Ns
)
*
1e3
}
func
(
r
BenchmarkResult
)
String
()
string
{
ns
:=
r
.
NsPerOp
()
mbs
:=
r
.
mbPerSec
()
mb
:=
""
if
ns
>
0
&&
r
.
Bytes
>
0
{
mb
=
fmt
.
Sprintf
(
"
\t
%7.2f MB/s"
,
(
float64
(
r
.
Bytes
)
/
1e6
)
/
(
float64
(
ns
)
/
1e9
)
)
if
mbs
!=
0
{
mb
=
fmt
.
Sprintf
(
"
\t
%7.2f MB/s"
,
mbs
)
}
return
fmt
.
Sprintf
(
"%8d
\t
%10d ns/op%s"
,
r
.
N
,
ns
,
mb
)
return
fmt
.
Sprintf
(
"%8d
\t
%10d ns/op%s"
,
r
.
N
,
r
.
NsPerOp
()
,
mb
)
}
// An internal function but exported because it is cross-package; part of the implementation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment