[visionegg] Re: smooth object motion
- From: Andrew Straw <astraw@xxxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Wed, 24 Aug 2005 10:51:15 -0700
I haven't had time to look at your code, but it seems you've had some
good suggestions regarding optimizing within a pure-Python context. If
that doesn't get the speed you need, I'd suggest looking at Pyrex which
allows you to smoothly transition from Python to C in incremental
steps. (It basically is a very Python-like language which compiles .pyx
files into .c files allowing mixing of Python and C calls.) You could
make calls to the C API of OpenGL and gradually transition only those
bits of Python code to C where the bottlenecks are.
Also, WRT profiling, I can suggest a VERY nice solution: The hotshot
profiler and the hotshot2cachegrind script of
http://kcachegrind.sourceforge.net/cgi-bin/show.cgi . I think this is
linux only...
Cheers!
Andrew
On Aug 24, 2005, at 9:18 AM, Simeon Fitch wrote:
Gabriel,
How complicated are your objects, in terms of vertices/polygons? If
each drawing routine is making a lot of GL calls (which are quite
expensive, probably more so than the interpreter loop), you could
reduce the number of those calls with display lists and/or vertex
arrays.
Have you tried running to code in the profiler to figure out exactly
where you bottle neck is? (See
http://docs.python.org/lib/profile.html) Your experience may be
different, but every time I try to guess what is causing my program to
run slowly, I'm wrong! :-)
If you find a fix, I think we'd all be interested in knowing what the
problem was and your fix for it.
Best,
Simeon
On 8/23/05, Gabriel Nevarez <nevarezg@xxxxxxxxxxxxx> wrote:
Hello, all,
I was hoping to recode some multiple-object-tracking studies in
VisionEgg. So,
thinking that it'd be nice that I finally get to do an
object-oriented version
of an object-tracking program, I go about it, only to realize that the
interpreter overhead makes the final program too slow to be useful.
Essentially, I create anywhere from 1 to 10 objects, giving them
individual
properties (i.e, size, shape, position, orientation, etc) and append
them in a
list, then I iterate through their trajectories, themselves part of
the object,
(generated offline and loaded before each trial) for each object, as
such:
g_num_objects = 8
g_num_cycles = 1000
## in main experiment loop ##
for j in xrange (g_num_cycles):
for i in xrange(g_num_objects):
object_list[i].position =
object_list[i].trajectory_list[j]
drawScreen()
It works exactly as intended.... but *horribly* slow!
Any suggestions on optimizing overall script speed? Have looked into
the
generally-recommended performance-enhancing python tips (such as
http://www.szgti.bmf.hu/harp/python/fastpython.html), but seems the
main speed
bottleneck is the interpreter moving up and down the call stack
within the
embedded loops, so I would need to restructure the object position
updates in a
different way from the embedded loops I currently have. I noticed
the Dots.py
demo uses the Numeric package to optimize object movement, which I'm
currently
looking into.
Any tips?
cheers,
-=Gabriel Nevarez
Research Programmer
Psychology Department
Cardiff University
http://www.cf.ac.uk/psych
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
--
Simeon H.K. Fitch, Owner
Mustard Seed Software
http://www.mseedsoft.com/
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- References:
- [visionegg] smooth object motion
- From: Gabriel Nevarez
- [visionegg] Re: smooth object motion
- From: Simeon Fitch
Other related posts:
- » [visionegg] smooth object motion
- » [visionegg] Re: smooth object motion
- » [visionegg] Re: smooth object motion
- » [visionegg] Re: smooth object motion
Gabriel,
How complicated are your objects, in terms of vertices/polygons? If each drawing routine is making a lot of GL calls (which are quite expensive, probably more so than the interpreter loop), you could reduce the number of those calls with display lists and/or vertex arrays.
Have you tried running to code in the profiler to figure out exactly where you bottle neck is? (See http://docs.python.org/lib/profile.html) Your experience may be different, but every time I try to guess what is causing my program to run slowly, I'm wrong! :-)
If you find a fix, I think we'd all be interested in knowing what the problem was and your fix for it.
Best,
Simeon
On 8/23/05, Gabriel Nevarez <nevarezg@xxxxxxxxxxxxx> wrote:
Hello, all,
I was hoping to recode some multiple-object-tracking studies in VisionEgg. So,
thinking that it'd be nice that I finally get to do an object-oriented version
of an object-tracking program, I go about it, only to realize that the
interpreter overhead makes the final program too slow to be useful.
Essentially, I create anywhere from 1 to 10 objects, giving them individual
properties (i.e, size, shape, position, orientation, etc) and append them in a
list, then I iterate through their trajectories, themselves part of the object,
(generated offline and loaded before each trial) for each object, as such:
g_num_objects = 8 g_num_cycles = 1000
## in main experiment loop ##
for j in xrange (g_num_cycles):
for i in xrange(g_num_objects):
object_list[i].position = object_list[i].trajectory_list[j]
drawScreen()
It works exactly as intended.... but *horribly* slow!
Any suggestions on optimizing overall script speed? Have looked into the
generally-recommended performance-enhancing python tips (such as
http://www.szgti.bmf.hu/harp/python/fastpython.html), but seems the main speed
bottleneck is the interpreter moving up and down the call stack within the
embedded loops, so I would need to restructure the object position updates in a
different way from the embedded loops I currently have. I noticed the Dots.py
demo uses the Numeric package to optimize object movement, which I'm currently
looking into.
Any tips?
cheers,
-=Gabriel Nevarez Research Programmer Psychology Department Cardiff University http://www.cf.ac.uk/psych
====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
-- Simeon H.K. Fitch, Owner Mustard Seed Software http://www.mseedsoft.com/ ====================================== The Vision Egg mailing list Archives: http://www.freelists.org/archives/visionegg Website: http://www.visionegg.org/mailinglist.html
- [visionegg] smooth object motion
- From: Gabriel Nevarez
- [visionegg] Re: smooth object motion
- From: Simeon Fitch