[Melbourne-pm] Timer::HiRes and alarms?

Daniel Pittman daniel at rimspace.net
Wed Nov 10 22:16:46 PST 2010


Toby Corkindale <toby.corkindale at strategicdata.com.au> writes:
> On 11/11/10 16:46, Daniel Pittman wrote:
>> Toby Corkindale<toby.corkindale at strategicdata.com.au>  writes:
>>> On 11/11/10 15:56, Kim Hawtin wrote:
>>>> Toby Corkindale wrote:
>>>> I was getting restless about frequently timing out. Used NYTProfile. Did
>>>> away with all the hashes and implemented them in arrays. Used constants
>>>> for indexes instead of hash keys. Went from 980ms to typically 270ms per
>>>> turn. Now it only times out when theres more than 100 or so of my fleets
>>>> on the move and that seems to be the parsing code ...
>>>
>>> Hmm, interesting to hear.
>>> So, the array methods are quicker than hashes for small sets?
>>
>> They should be faster than a hash for *any* set, because they are a constant
>> time access with zero computation, rather than a just-above-constant time
>> access with some computation.
>
> I was confused by how it could be computation-free for a moment, then realised
> you're talking about accessing things by doing $planets[$id], which of course
> is quicker than $planets->{$id}.

I was talking about the more general case of array vs hash, where access is
zero-cost "index times size" vs some-cost "index through hash, then walk past
collisions".  (Presumably your comment about speed wasn't quite so
restricted. :)

        Daniel

-- 
✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons


More information about the Melbourne-pm mailing list