[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gawk array index: string vs integer
From: |
J Naman |
Subject: |
gawk array index: string vs integer |
Date: |
Tue, 12 Dec 2023 00:55:38 -0500 |
Recently, Ed wrote,"Using a string `"tos"` instead of a number `0` for the
top of a stack index makes the script run about 3 times slower."
When I benchmarked it, I consistently got a 5% difference, which is slower,
but not 3x.
Process: I split()a string of numbers to an array (thus indexed
1->n),copied that array, and set array1[0]=an integer and array2["tos"]=
the same integer
Looping 80 million times, the difference was 5%. Different loop counts were
5% too.
Presumably the 3x difference was true in some older gawk versions, but it
does not seem to be now. Or I got it wrong ... -john Naman
- gawk array index: string vs integer,
J Naman <=