by Hello71 · 6y ago · 0 comments
One thing I'm wondering is how's the startup time/performance in general? awk is kinda slow overall, but Python starts a little too slow to be used in shell scripting.
And sure enough, it's both easy and reasonably fast to run:
$ time seq 1 10000 | awk '{a+=$0}END{print a}'
50005000
seq 1 10000 0.00s user 0.00s system 91% cpu 0.002 total
awk '{a+=$0}END{print a}' 0.01s user 0.00s system 95% cpu 0.008 total
$ time seq 1 10000 | python3 pyp.py 'sum(map(int, lines))'
50005000
seq 1 10000 0.00s user 0.00s system 80% cpu 0.002 total
python3 pyp.py 'sum(map(int, lines))' 0.06s user 0.01s system 99% cpu 0.070 total
I wouldn't run it in a loop, but it's definitely a contender even in high-ish performance situations.