Created
November 14, 2016 23:14
-
-
Save anonymous/da6433854e67a1062ed36a668444dae1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ du -sh top10mm.txt | |
200M top10mm.txt | |
$ cat wc.pl | |
#!/usr/bin/env perl | |
#use strict; | |
#use warnings; | |
#use diagnostics; | |
$words = 0; | |
$lines = 0; | |
while( my $line = <>) { | |
@array = split /\s+/, $line; | |
$words += scalar @array; | |
$lines += 1 | |
} | |
print "$lines $words\n"; | |
##### PERL | |
$ time cat top10mm.txt | ./wc.pl | |
10000000 40000000 | |
real 0m9.479s | |
user 0m9.444s | |
sys 0m0.356s | |
##### system wc | |
$ time wc -lw top10mm.txt | |
10000000 40000000 top10mm.txt | |
real 0m2.083s | |
user 0m2.060s | |
sys 0m0.020s | |
### crystal ( https://github.com/sferik/wc.cr ) | |
$ time ./wcg top10mm.txt | |
10000000 40000000 top10mm.txt | |
real 0m42.592s | |
user 0m5.528s | |
sys 0m40.480s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment