4 ms·
Any notable difference if you pipe the file in, rather than read from disk? IO caches are a thing as well, don’t use the first measurement.
by orf 2y ago
Any notable difference if you pipe the file in, rather than read from disk?
IO caches are a thing as well, don’t use the first measurement.
- JackSlateur 2y agoI've accounted for IO cache, the test is running from an in-memory dataset After checking a bit more, wc2 is indeed faster than wc in a specific use case: counting characters. That is, transforming a sequence of one or multiple bytes into meaningful character (wc --chars somefile). In wc, the related code is here: https://github.com/coreutils/coreutils/blob/master/src/wc.c#L444 https://github.com/coreutils/coreutils/blob/master/src/wc.c#... So in the end, wc uses the function while wc2 does not: https://en.cppreference.com/w/c/string/multibyte/mbrtoc32 https://en.cppreference.com/w/c/string/multibyte/mbrtoc32 Now, what I cannot tell : is wc2's code really comparable versus mbrtoc32 ? From a couple of tests, it works against ascii and utf8 dataset, but is that all ? Or are there edgecases cleverly handled by mbrtoc32 (with a performance cost) ?