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
cb9759d0
Commit
cb9759d0
authored
May 30, 2012
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/bench/go1: add mandelbrot for floating point
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/6244063
parent
de96df1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
mandel_test.go
test/bench/go1/mandel_test.go
+41
-0
No files found.
test/bench/go1/mandel_test.go
0 → 100644
View file @
cb9759d0
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This benchmark, taken from the shootuot, tests floating point performance.
package
go1
import
"testing"
func
mandelbrot
(
n
int
)
int
{
const
Iter
=
50
const
Zero
float64
=
0
const
Limit
=
2.0
ok
:=
0
for
y
:=
0
;
y
<
n
;
y
++
{
for
x
:=
0
;
x
<
n
;
x
++
{
Zr
,
Zi
,
Tr
,
Ti
:=
Zero
,
Zero
,
Zero
,
Zero
Cr
:=
(
2
*
float64
(
x
)
/
float64
(
n
)
-
1.5
)
Ci
:=
(
2
*
float64
(
y
)
/
float64
(
n
)
-
1.0
)
for
i
:=
0
;
i
<
Iter
&&
(
Tr
+
Ti
<=
Limit
*
Limit
);
i
++
{
Zi
=
2
*
Zr
*
Zi
+
Ci
Zr
=
Tr
-
Ti
+
Cr
Tr
=
Zr
*
Zr
Ti
=
Zi
*
Zi
}
if
Tr
+
Ti
<=
Limit
*
Limit
{
ok
++
}
}
}
return
ok
}
func
BenchmarkMandelbrot200
(
b
*
testing
.
B
)
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
mandelbrot
(
200
)
}
}
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