[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT coroutine v. function benchmark
- From: Mike Pall <mikelu-1007@...>
- Date: Sat, 3 Jul 2010 10:09:38 +0200
Peter Jin wrote:
> I'm curious as to what might be causing the difference in runtimes. Please
> see the comments below. As indicated, declaring "x" as local causes
> somewhere between 1.5-1.8 times slow down for the coroutine loop compared to
> the function calls, whereas they have nearly identical times otherwise. I am
> running this on an AMD Phenom II X4 920 machine, with the latest LuaJIT 2.0
> source from the development branch. Am I missing something something obvious
> about LuaJIT coroutines that explains this?
All variants are the exact same speed on my CPU.
You've probably forgotten to disable the power-saving features of
your CPU/OS. The runtimes are quite short, so this is running at a
fraction of the CPU frequency for the first part and then at full
speed towards the end of each run. The delay until the CPU goes
full speed is more or less random or depends on unrelated things
(e.g. more system-calls due to memory allocation from
I suggest to read the "Measurement Methods" section in:
> FYI I should add that, using gcc -O2 -msse2 etc., the plain C version of
> loopy() performs 1.5x slower using int, and 3x slower using double.
Umm, what is running slower than what? The loop runs at exactly
the same speed as a C version (using doubles).
BTW: Please don't call this a benchmark or try to infer anything
from it. It's a trivial loop and has zero practical significance.