[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Performance of coroutine resume/yield
- From: Brian Hook <hook_l@...>
- Date: Mon, 1 Mar 2004 12:05:02 -0500
Okay, so it sounds like they should be fairly lightweight. I did a
quick test using a single coroutine that was nothing more than just an
infinite loop with a yield, and on my Pentium-M 1.5GHz I managed to
achieve 1.54M yields/second.
Factoring out loop overhead for the benchmark, it's closer to 1.7M
I then switched to a table of 1000 coroutines instead of calling the
same coroutine over and over, and the performance dropped (including
table iteration) to 1.23M yields/second, but factoring out the table
iteration it climbs back up to around 1.7M yields/second.
This is using the 5.0 prebuilt binary off of the Wiki.
So it's about 880 clock cycles per resume/yield pair, which seems
pretty reasonable to me -- that's going to be absorbed into the noise
compared to the actual work happening in the coroutines, but if I have
enough idling objects I _might_ be better served having an external
guard that prevents the resume in a no-op case.