coreutils
[Top][All Lists]
Advanced

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

performance bug of `wc -m`


From: Peng Yu
Subject: performance bug of `wc -m`
Date: Sat, 12 May 2018 21:55:40 -0400

Hi,

The following example shows that `wc -m` is even slower than the
equivalent Python code. Can this performance bug be fixed?

$ cat wcm.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:

import sys
l = 0
for line in sys.stdin:
    l += len(line.rstrip('\n').decode('utf-8'))
print l

$ time ./wcm.py < 1.txt
6786930

real    0m0.155s
user    0m0.059s
sys    0m0.048s
$ time wc -m < 1.txt
6796930

real    0m2.350s
user    0m2.280s
sys    0m0.017s

-- 
Regards,
Peng



reply via email to

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