Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
46a9d0fe
Commit
46a9d0fe
authored
May 14, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert benchmark to Py3
parent
ce7ad25e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Demos/benchmarks/nbody.py
Demos/benchmarks/nbody.py
+6
-6
No files found.
Demos/benchmarks/nbody.py
View file @
46a9d0fe
...
@@ -18,7 +18,7 @@ __contact__ = "collinwinter@google.com (Collin Winter)"
...
@@ -18,7 +18,7 @@ __contact__ = "collinwinter@google.com (Collin Winter)"
# Python imports
# Python imports
import
optparse
import
optparse
import
sys
import
sys
import
time
from
time
import
time
# Local imports
# Local imports
import
util
import
util
...
@@ -26,7 +26,7 @@ import util
...
@@ -26,7 +26,7 @@ import util
def
combinations
(
l
):
def
combinations
(
l
):
"""Pure-Python implementation of itertools.combinations(l, 2)."""
"""Pure-Python implementation of itertools.combinations(l, 2)."""
result
=
[]
result
=
[]
for
x
in
x
range
(
len
(
l
)
-
1
):
for
x
in
range
(
len
(
l
)
-
1
):
ls
=
l
[
x
+
1
:]
ls
=
l
[
x
+
1
:]
for
y
in
ls
:
for
y
in
ls
:
result
.
append
((
l
[
x
],
y
))
result
.
append
((
l
[
x
],
y
))
...
@@ -78,7 +78,7 @@ PAIRS = combinations(SYSTEM)
...
@@ -78,7 +78,7 @@ PAIRS = combinations(SYSTEM)
def
advance
(
dt
,
n
,
bodies
=
SYSTEM
,
pairs
=
PAIRS
):
def
advance
(
dt
,
n
,
bodies
=
SYSTEM
,
pairs
=
PAIRS
):
for
i
in
x
range
(
n
):
for
i
in
range
(
n
):
for
(([
x1
,
y1
,
z1
],
v1
,
m1
),
for
(([
x1
,
y1
,
z1
],
v1
,
m1
),
([
x2
,
y2
,
z2
],
v2
,
m2
))
in
pairs
:
([
x2
,
y2
,
z2
],
v2
,
m2
))
in
pairs
:
dx
=
x1
-
x2
dx
=
x1
-
x2
...
@@ -129,12 +129,12 @@ def test_nbody(iterations):
...
@@ -129,12 +129,12 @@ def test_nbody(iterations):
report_energy
()
report_energy
()
times
=
[]
times
=
[]
for
_
in
x
range
(
iterations
):
for
_
in
range
(
iterations
):
t0
=
time
.
time
()
t0
=
time
()
report_energy
()
report_energy
()
advance
(
0.01
,
20000
)
advance
(
0.01
,
20000
)
report_energy
()
report_energy
()
t1
=
time
.
time
()
t1
=
time
()
times
.
append
(
t1
-
t0
)
times
.
append
(
t1
-
t0
)
return
times
return
times
...
...
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