summaryrefslogtreecommitdiff
path: root/Demos
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2015-10-01 11:12:35 +0200
committerStefan Behnel <stefan_ml@behnel.de>2015-10-01 11:12:35 +0200
commit5dc357fef34ee852ce7ef1b38fcbb572556f0689 (patch)
tree204d8263fe78775b1f63e51070a84c682a6e984c /Demos
parent6eed305ada04e6e6bf9322447c0f83c26f132a6b (diff)
downloadcython-5dc357fef34ee852ce7ef1b38fcbb572556f0689.tar.gz
speed up chaos benchmark some more
Diffstat (limited to 'Demos')
-rw-r--r--Demos/benchmarks/chaos.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Demos/benchmarks/chaos.py b/Demos/benchmarks/chaos.py
index faaecec59..36bd1bcd3 100644
--- a/Demos/benchmarks/chaos.py
+++ b/Demos/benchmarks/chaos.py
@@ -97,7 +97,8 @@ class Spline(object):
self.knots[len(self.knots) - self.degree])
@cython.locals(ik=cython.long, ii=cython.long, I=cython.long,
- ua=cython.long, ub=cython.long, u=cython.double)
+ ua=cython.long, ub=cython.long, u=cython.double,
+ dom=(cython.long, cython.long))
def __call__(self, u):
"""Calculates a point of the B-Spline using de Boors Algorithm"""
dom = self.GetDomain()
@@ -121,7 +122,7 @@ class Spline(object):
d[index] = d[index].linear_combination(d[index + 1], co1, co2)
return d[0]
- @cython.locals(ii=cython.long, I=cython.long)
+ @cython.locals(ii=cython.long, I=cython.long, dom=(cython.long, cython.long))
def GetIndex(self, u):
dom = self.GetDomain()
for ii in range(self.degree - 1, len(self.knots) - self.degree):
@@ -212,6 +213,7 @@ class Chaosgame(object):
if point.y < self.miny:
point.y = self.miny
+ @cython.locals(x=cython.long, y=cython.long)
def create_image_chaos(self, timer, w, h, n):
im = [[1] * h for i in range(w)]
point = GVector((self.maxx + self.minx) / 2,
@@ -221,10 +223,8 @@ class Chaosgame(object):
t1 = timer()
for i in range(5000):
point = self.transform_point(point)
- x = (point.x - self.minx) / self.width * w
- y = (point.y - self.miny) / self.height * h
- x = int(x)
- y = int(y)
+ x = int((point.x - self.minx) / self.width * w)
+ y = int((point.y - self.miny) / self.height * h)
if x == w:
x -= 1
if y == h: