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: Wolfgang Laun
Subject: Re: [bug-gawk] Is the speed of array index checking same as string comparison?
Date: Mon, 26 Nov 2018 11:27:31 +0100

An astronomer, a physicist and a mathematician are on a train in Scotland.
The astronomer looks out of the window, sees a black sheep standing in a
field, and remarks, "How odd. Scottish sheep are black." "No, no, no!" says
the physicist. "Only some Scottish sheep are black." The mathematician
rolls his eyes at his companions' muddled thinking and says, "In Scotland,
there is at least one field, containing at least one sheep, at least one
side of which appears black from here."

Now we know what a computer scientist might say. "All sheep in Scotland are
equal because it takes the same time to share them." (Pun intended.)

-W

On Mon, 26 Nov 2018 at 11:07, Peng Yu <address@hidden> wrote:

> Hi,
>
> In the following example, it shows that the performance of array index
> checking is same as string comparison. Is this conclusion always true?
> Thanks.
>
> $ time awk ' BEGIN {d["NA"]=1; for(i=1;i<=100000000;++i) ("NA" in d) }'
>
> real    0m7.259s
> user    0m7.024s
> sys    0m0.070s
> $ time awk ' BEGIN {x="NA"; for(i=1;i<=100000000;++i) x=="NA" }'
>
> real    0m7.214s
> user    0m6.970s
> sys    0m0.066s
>
> --
> Regards,
> Peng
>
>


reply via email to

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