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
8475832f
Commit
8475832f
authored
Jun 27, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: scale benchmark precision to 0.01ns if needed
R=dvyukov, r CC=golang-dev
https://golang.org/cl/4657053
parent
6aaa86ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
benchmark.go
src/pkg/testing/benchmark.go
+12
-1
No files found.
src/pkg/testing/benchmark.go
View file @
8475832f
...
...
@@ -174,7 +174,18 @@ func (r BenchmarkResult) String() string {
if
mbs
!=
0
{
mb
=
fmt
.
Sprintf
(
"
\t
%7.2f MB/s"
,
mbs
)
}
return
fmt
.
Sprintf
(
"%8d
\t
%10d ns/op%s"
,
r
.
N
,
r
.
NsPerOp
(),
mb
)
nsop
:=
r
.
NsPerOp
()
ns
:=
fmt
.
Sprintf
(
"%10d ns/op"
,
nsop
)
if
r
.
N
>
0
&&
nsop
<
100
{
// The format specifiers here make sure that
// the ones digits line up for all three possible formats.
if
nsop
<
10
{
ns
=
fmt
.
Sprintf
(
"%13.2f ns/op"
,
float64
(
r
.
Ns
)
/
float64
(
r
.
N
))
}
else
{
ns
=
fmt
.
Sprintf
(
"%12.1f ns/op"
,
float64
(
r
.
Ns
)
/
float64
(
r
.
N
))
}
}
return
fmt
.
Sprintf
(
"%8d
\t
%s%s"
,
r
.
N
,
ns
,
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