Commit a3e02d9a authored by Stefan Behnel's avatar Stefan Behnel

convert benchmark to Py3

parent 46a9d0fe
...@@ -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: # xrange(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 xrange(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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment