bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Is the speed of array index checking same as string compa


From: arnold
Subject: Re: [bug-gawk] Is the speed of array index checking same as string comparison?
Date: Mon, 26 Nov 2018 04:39:03 -0700
User-agent: Heirloom mailx 12.4 7/29/08

Peng Yu <address@hidden> wrote:

> In the following example, it shows that the performance of array index
> checking is same as string comparison. Is this conclusion always true?

No.  The example only had one element in it, so the lookup time is
close to that of a single string comparison.

Awk arrays are hash tables.  As they fill up, access will slow down.
That said, gawk goes to a lot of trouble to try to keep access fast,
with a small number of collisions per bucket on average.  I suspect you'd
have to REALLY load an array before you'd notice a big difference
(millions of elements on modern machines).

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]