- or download this
$ for i in $(seq 1 210); do cat large.txt; done >/tmp/big.txt
$ ls -lh /tmp/big.txt
-rw-r--r-- 1 mario mario 5.0G May 19 11:19 /tmp/big.txt
- or download this
$ time grep -c "[aA].*[eE].*[iI].*[oO].*[uU]" /tmp/big.txt
2195760
...
real 0m8.721s
user 0m8.317s
sys 0m0.404s
- or download this
$ time ./egrep.pl --max-workers=2 -c "[aA].*[eE].*[iI].*[oO].*[uU]" /t
+mp/big.txt
2195760
...
real 0m39.068s 0m16.088s 0m8.146s 0m4.229s 0m3.084s
user 1m17.614s 1m19.624s 1m20.441s 1m21.823s 1m25.296s
sys 0m0.419s 0m0.464s 0m0.434s 0m0.526s 0m0.645s
- or download this
$ time NUM_THREADS=2 ./grep-count-pcre2 "[aA].*[eE].*[iI].*[oO].*[uU]"
+ /tmp/big.txt
parallel (2) Total Lines: 105000000, Matching Lines: 2195760
...
real 0m9.256s 0m4.382s 0m2.748s 0m1.929s 0m1.689s
user 0m15.858s 0m16.563s 0m17.267s 0m18.391s 0m19.497s
sys 0m1.678s 0m1.339s 0m1.186s 0m1.225s 0m1.260s
- or download this
$ time NUM_THREADS=2 ./grep-count-pmap "[aA].*[eE].*[iI].*[oO].*[uU]"
+/tmp/big.txt
parallel (2) Total Lines: 105000000, Matching Lines: 2195760
...
real 0m8.113s 0m3.249s 0m1.675s 0m0.958s 0m0.707s
user 0m15.333s 0m15.646s 0m15.809s 0m16.775s 0m18.110s
sys 0m0.840s 0m0.266s 0m0.343s 0m0.489s 0m0.506s
- or download this
$ time NUM_THREADS=2 ./grep-count-chunk "[aA].*[eE].*[iI].*[oO].*[uU]"
+ /tmp/big.txt
parallel (2) Total Lines: 105000000, Matching Lines: 2195760
...
real 0m8.017s 0m3.257s 0m1.537s 0m0.801s 0m0.618s
user 0m14.524s 0m14.997s 0m14.906s 0m15.397s 0m17.519s
sys 0m1.010s 0m1.019s 0m0.412s 0m0.515s 0m0.649s
- or download this
// Grep PCRE2 and Chunking C++ OpenMP demonstration for website:
// https://cpufun.substack.com/p/processing-a-file-with-openmp
...
return 0;
}