Why is the wc utility so slow?When I run it on a large file, it takes about 20 times longer than md5sum:MyDesktop:/tmp$ dd if=/dev/zero bs=1024k count=1024 of=/tmp/bigfile1024+0 records in1024+0 records out1073741824 bytes (1.1 GB) copied, 0.687094 s, 1.6 GB/sMyDesktop:/tmp$ time wc /tmp/bigfile          0          0 1073741824 /tmp/bigfilereal    0m45.969suser    0m45.424ssys     0m0.424sMyDesktop:/tmp$ time md5sum /tmp/bigfile cd573cfaace07e7949bc0c46028904ff  /tmp/bigfilereal    0m2.520suser    0m2.196ssys     0m0.316sIt's not just a weird edge condition cause by the file being full of nulls, I see the same difference in performance even if the file is filled with random data or is a text file.(this is on Ubuntu 13.04, 64 bit)
Why is wc so slow?
performance;wc