dnschneid/crouton — pull request #450 by drinkcat (2013-10-25 15:52:32+00:00)
Title: Make croutonwheel work with both gawk and mawk.

Trying to make crouton awk-agnostic... `detectawk` was put in `installer/functions`, as it will be useful for `croutonclip` as well.

---

gawk does not support -W interactive: use fflush() instead (not POSIX, but supported by mawk and gawk).
However mawk does not obey fflush properly, so we still need to use -W interactive (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504)...

mawk is faster, so we prefer it if it is available, and fallback on gawk.

Time to parse ~300K croutonxi2events, on a Samsung ARM Chromebook:

Original code, using mawk:
real	0m9.746s
user	0m6.540s
sys	0m1.340s

Modified code, using mawk:
real	0m9.728s
user	0m5.825s
sys	0m1.315s

Modified code, using gawk:
real	0m11.212s
user	0m9.070s
sys	0m1.320s

Modified code performs identically to original one on mawk. gawk incurs a ~50% performance penalty.