bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] SYMTAB["x"] is much slower than `x`


From: Peng Yu
Subject: [bug-gawk] SYMTAB["x"] is much slower than `x`
Date: Mon, 26 Nov 2018 16:40:19 -0600

Hi,

The following example shows that SYMTAB["x"] is much slower than `x`.
What is the difference between the implementation of SYMTAB["x"] and
`x`. Can the performance be improved for SYMTAB["x"]?

TIMEFORMAT=%R
n=100000000
time1=$(( time awk -v n="$n" -e 'BEGIN { for(i=0;i<n;++i) { } }') 2>&1)
time2=$(( time awk -v n="$n" -e 'BEGIN { for(i=0;i<n;++i) SYMTAB["x"]
= 1 }') 2>&1)
time3=$(( time awk -v n="$n" -e 'BEGIN { for(i=0;i<n;++i) x = 1 }') 2>&1)

printf '%s\t%s\t%s\t%s\n' "$time1" "$time2" "$time3" "$(bc -l <<<
"($time2-$time1)/($time3-$time1)")"
3.966    8.305    4.315    12.43266475644699140401

-- 
Regards,
Peng



reply via email to

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