<div class="gmail_quote">On Wed, Aug 26, 2009 at 2:40 PM, Simon Wittber <span dir="ltr"><<a href="mailto:simonwittber@gmail.com">simonwittber@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Aug 26, 2009 at 5:31 PM, Dan Sanduleac<<a href="mailto:sanduleac.dan@gmail.com">sanduleac.dan@gmail.com</a>> wrote:<br>
> The testing goes like this: each "tick", 10000 objects update their<br>
> position, according to their velocity and timedelta since last "tick", and<br>
> I'm measuring the average time a tick takes to complete.<br>
<br>
</div>I know that I'm not answering your question, but I thought I might<br>
throw in some advice, if you have a need for speed.<br>
<br>
It would be much faster to create an Vec3Array type object, and do the<br>
loop iteration with the += operating inside C++. This would make your<br>
Python API look something like:<br>
<br>
positions = Vec3Array(10000)<br>
velocities = Vec3Array(10000)<br>
positions += velocities<br>
<br>
Also, Stackless will have little effect your benchmarks, so you may<br>
find more answers in a more general forum.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
:: Simon Wittber<br>
:: <a href="http://www.linkedin.com/in/simonwittber" target="_blank">http://www.linkedin.com/in/simonwittber</a><br>
:: phone: +61.4.0135.0685<br>
:: jabber/msn: <a href="mailto:simonwittber@gmail.com">simonwittber@gmail.com</a></font></blockquote><div><br>Thanks for the reply :D<br>I know, I posted on the c++-sig list first, but didn't get an answer there so I decided to post on stackless too. <br>
<br>What you're suggesting would of course speed up the process dramatically, but each of those objects lives in its own tasklet, and I wanted to simulate 10000 objects each performing some action (per game tick), say updating its position, in its "run-loop". Because of this, I couldn't code the loop in C, as I'm stuck with the one from stackless' scheduler.<br>
<br>Of course, in a real game, the position wouldn't be updated by each object in its own thread. There would be a second stage in which a faster (compiled) physics engine would do this. However, this was just for testing and I couldn't think of something else.<br>
<br>OvermindDL1 solved my problem, letting me know that I was dealing with heavy function call overhead, which added up because I was calling C functions from python at a very fast rate.<br></div></div><br>