3 ms·
I had to find the longest line in a really big file and tried both awk and Perl. I was surprised at how much faster Perl was: http://alquerubim.blogspot.com.br
by forinti 9y ago
I had to find the longest line in a really big file and tried both awk and Perl. I was surprised at how much faster Perl was:
http://alquerubim.blogspot.com.br/2016/09/a-linha-mais-comprida-de-um-arquivo-ii.html http://alquerubim.blogspot.com.br/2016/09/a-linha-mais-compr...
Still, awk was simpler.
- kazinator 9y agoYour benchmark doesn't specify which implementation of Awk you're testing, and which version of it. Your code is verbose: length($0) shortens to just length: awk 'length > max { max = length } END { print max }' The Perl seems to have an off-by-one error.