summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-08-21 00:28:52 -0600
committerTavian Barnes <tavianator@gmail.com>2011-08-21 13:18:28 -0600
commit6b1fcde7af64ca81079dffe1d62096228693b5d6 (patch)
tree2600ece91b5179105a572d79b60a6fc07e82c0a7 /libdimension-python
parent4f9a96f6cdee4cf234bde7fdafd0be0f5b6b808e (diff)
downloaddimension-6b1fcde7af64ca81079dffe1d62096228693b5d6.tar.xz
Don't dynamically allocate timers.
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pxd9
-rw-r--r--libdimension-python/dimension.pyx20
2 files changed, 9 insertions, 20 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index a3523d0..7b3ba6e 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -84,9 +84,8 @@ cdef extern from "../libdimension/dimension.h":
double user
double system
- dmnsn_timer *dmnsn_new_timer()
- void dmnsn_complete_timer(dmnsn_timer *timer)
- void dmnsn_delete_timer(dmnsn_timer *timer)
+ void dmnsn_start_timer(dmnsn_timer *timer)
+ void dmnsn_stop_timer(dmnsn_timer *timer)
############
# Geometry #
@@ -392,8 +391,8 @@ cdef extern from "../libdimension/dimension.h":
double adc_bailout
unsigned int nthreads
- dmnsn_timer *bounding_timer
- dmnsn_timer *render_timer
+ dmnsn_timer bounding_timer
+ dmnsn_timer render_timer
dmnsn_scene *dmnsn_new_scene()
void dmnsn_delete_scene(dmnsn_scene *scene)
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 0c0c214..d0bd4e7 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -87,7 +87,7 @@ cdef _Progress(dmnsn_progress *progress):
cdef class Timer:
"""A timer for Dimension tasks."""
- cdef dmnsn_timer *_timer
+ cdef dmnsn_timer _timer
def __init__(self):
"""
@@ -95,14 +95,11 @@ cdef class Timer:
Timing starts as soon as the object is created.
"""
- self._timer = dmnsn_new_timer()
+ dmnsn_start_timer(&self._timer)
- def __dealloc__(self):
- dmnsn_delete_timer(self._timer)
-
- def complete(self):
+ def stop(self):
"""Stop the Timer."""
- dmnsn_complete_timer(self._timer)
+ dmnsn_stop_timer(&self._timer)
property real:
"""Real (wall clock) time."""
@@ -121,10 +118,9 @@ cdef class Timer:
return "%.2fs (user: %.2fs; system: %.2fs)" % \
(self._timer.real, self._timer.user, self._timer.system)
-cdef _Timer(dmnsn_timer *timer):
+cdef _Timer(dmnsn_timer timer):
cdef Timer self = Timer.__new__(Timer)
self._timer = timer
- DMNSN_INCREF(self._timer)
return self
############
@@ -1450,16 +1446,10 @@ cdef class Scene:
property bounding_timer:
"""The Timer for building the bounding hierarchy."""
def __get__(self):
- if self._scene.bounding_timer == NULL:
- raise RuntimeError("scene has not been rendered yet")
-
return _Timer(self._scene.bounding_timer)
property render_timer:
"""The Timer for the actual render."""
def __get__(self):
- if self._scene.render_timer == NULL:
- raise RuntimeError("scene has not been rendered yet")
-
return _Timer(self._scene.render_timer)
def raytrace(self):