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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
a3e02d9a
Commit
a3e02d9a
authored
May 14, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert benchmark to Py3
parent
46a9d0fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
Demos/benchmarks/richards.py
Demos/benchmarks/richards.py
+12
-12
No files found.
Demos/benchmarks/richards.py
View file @
a3e02d9a
...
@@ -135,9 +135,9 @@ def trace(a):
...
@@ -135,9 +135,9 @@ def trace(a):
global
layout
global
layout
layout
-=
1
layout
-=
1
if
layout
<=
0
:
if
layout
<=
0
:
print
print
()
layout
=
50
layout
=
50
print
a
,
print
(
a
,
end
=
''
)
TASKTABSIZE
=
10
TASKTABSIZE
=
10
...
@@ -302,10 +302,10 @@ class IdleTask(Task):
...
@@ -302,10 +302,10 @@ class IdleTask(Task):
if
i
.
count
==
0
:
if
i
.
count
==
0
:
return
self
.
hold
()
return
self
.
hold
()
elif
i
.
control
&
1
==
0
:
elif
i
.
control
&
1
==
0
:
i
.
control
/=
2
i
.
control
/
/
=
2
return
self
.
release
(
I_DEVA
)
return
self
.
release
(
I_DEVA
)
else
:
else
:
i
.
control
=
i
.
control
/
2
^
0xd008
i
.
control
=
i
.
control
/
/
2
^
0xd008
return
self
.
release
(
I_DEVB
)
return
self
.
release
(
I_DEVB
)
...
@@ -333,7 +333,7 @@ class WorkTask(Task):
...
@@ -333,7 +333,7 @@ class WorkTask(Task):
pkt
.
ident
=
dest
pkt
.
ident
=
dest
pkt
.
datum
=
0
pkt
.
datum
=
0
for
i
in
BUFSIZE_RANGE
:
#
x
range(BUFSIZE)
for
i
in
BUFSIZE_RANGE
:
# range(BUFSIZE)
w
.
count
+=
1
w
.
count
+=
1
if
w
.
count
>
26
:
if
w
.
count
>
26
:
w
.
count
=
1
w
.
count
=
1
...
@@ -351,7 +351,7 @@ def schedule():
...
@@ -351,7 +351,7 @@ def schedule():
pkt
=
None
pkt
=
None
if
tracing
:
if
tracing
:
print
"tcb ="
,
t
.
ident
print
(
"tcb ="
,
t
.
ident
)
if
t
.
isTaskHoldingOrWaiting
():
if
t
.
isTaskHoldingOrWaiting
():
t
=
t
.
link
t
=
t
.
link
...
@@ -362,7 +362,7 @@ def schedule():
...
@@ -362,7 +362,7 @@ def schedule():
class
Richards
(
object
):
class
Richards
(
object
):
def
run
(
self
,
iterations
):
def
run
(
self
,
iterations
):
for
i
in
x
range
(
iterations
):
for
i
in
range
(
iterations
):
taskWorkArea
.
holdCount
=
0
taskWorkArea
.
holdCount
=
0
taskWorkArea
.
qpktCount
=
0
taskWorkArea
.
qpktCount
=
0
...
@@ -403,15 +403,15 @@ def entry_point(iterations):
...
@@ -403,15 +403,15 @@ def entry_point(iterations):
return
result
,
startTime
,
endTime
return
result
,
startTime
,
endTime
def
main
(
entry_point
=
entry_point
,
iterations
=
10
):
def
main
(
entry_point
=
entry_point
,
iterations
=
10
):
print
"Richards benchmark (Python) starting... [%r]"
%
entry_point
print
(
"Richards benchmark (Python) starting... [%r]"
%
entry_point
)
result
,
startTime
,
endTime
=
entry_point
(
iterations
)
result
,
startTime
,
endTime
=
entry_point
(
iterations
)
if
not
result
:
if
not
result
:
print
"Incorrect results!"
print
(
"Incorrect results!"
)
return
-
1
return
-
1
print
"finished."
print
(
"finished."
)
total_s
=
endTime
-
startTime
total_s
=
endTime
-
startTime
print
"Total time for %d iterations: %.2f secs"
%
(
iterations
,
total_s
)
print
(
"Total time for %d iterations: %.2f secs"
%
(
iterations
,
total_s
)
)
print
"Average time per iteration: %.2f ms"
%
(
total_s
*
1000
/
iterations
)
print
(
"Average time per iteration: %.2f ms"
%
(
total_s
*
1000
/
iterations
)
)
return
42
return
42
try
:
try
:
...
...
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