lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


as usual when optimizing for speed, you just code naive, then profile
and optimizie only the 5% that use 95% of performance.
In your sieve this was very likely "canditate" a variable which is
used a lot in every innerst loop.

On Sat, Jan 22, 2011 at 7:34 AM, Steve Litt <slitt@troubleshooters.com> wrote:
> On Friday 21 January 2011 14:34:24 Axel Kittenberger wrote:
>> On Fri, Jan 21, 2011 at 8:10 PM, Alexander Gladysh <agladysh@gmail.com>
> wrote:
>> > On Fri, Jan 21, 2011 at 22:08, Steve Litt <slitt@troubleshooters.com>
> wrote:
>> >> On Friday 21 January 2011 03:48:02 Axel Kittenberger wrote:
>> >>> Ah, a sieve of eratosthenes (there are various ways to get primes). I
>> >>> suppose you will find a considerable perfomance increase (native and
>> >>> jit) if you use "candidate" as a local variable you pass as argument
>> >>> and return value to find_next_candidate() instead of storing it as
>> >>> "candidate" key in the prime array.
>> >>
>> >> Is table lookup really more expensive than passing in as an arg and
>> >> passing back as a return? Ugh!
>> >
>> > Try LJ2, you will think about these implementation details no longer. :-)
>>
>> Strange I didnt see that email :-/
>>
>> Lua Tables are hashtables. Putting and getting stuff from a hashtable
>> is of course slower than from a local variable (that is either on
>> stack or even a register)
>
> How much slower? To my way of thinking, tables of key/value pairs are the
> heart and soul of Lua. I'd hate to start worrying about speed when using them.
>
> SteveT
>
> Steve Litt
> Recession Relief Package
> http://www.recession-relief.US
> Twitter: http://www.twitter.com/stevelitt
>
>
>