Skip to content

Instantly share code, notes, and snippets.

@melezhik
Created June 22, 2021 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melezhik/8a74d4b45ac00736d82a3f0b08367339 to your computer and use it in GitHub Desktop.
Save melezhik/8a74d4b45ac00736d82a3f0b08367339 to your computer and use it in GitHub Desktop.
grep.regexp vs grep.contains for 2020_12 and 2021_06
[root@23f7111def19 r3tool]# SP6_FORMAT_TERSE=1 tomty --env=2020_12 pull_4383
load configuration from /root/projects/r3tool/.tomty/env/config.2020_12.pl6
index updated from file:///root/repo/api/v1/index
cat $root_dir/task.bash
$RAKUBIN -v
echo; echo; echo;
echo ".grep( { } )"
( time $RAKUBIN -e 'my $txt = slurp "/usr/share/dict/words"; for (1..1000) { my (@m) = $txt.grep( { m:i/ <!after i> e / } ) }' ) 2>&1
echo ===
echo "grep( *.contains )"
( time $RAKUBIN -e 'my $txt = slurp "/usr/share/dict/words"; for (1..1000) { my (@m) = $txt.grep( *.contains( /:i <!after i> e / ) ) }' ) 2>&1
echo ===
Welcome to Rakudo(tm) v2020.12.
Implementing the Raku(tm) programming language v6.d.
Built on MoarVM version 2020.12.
.grep( { } )
real 0m4.350s
user 0m4.315s
sys 0m0.157s
===
grep( *.contains )
real 0m4.116s
user 0m4.187s
sys 0m0.108s
===
[root@23f7111def19 r3tool]# SP6_FORMAT_TERSE=1 tomty --env=2021_06 pull_4383
load configuration from /root/projects/r3tool/.tomty/env/config.2021_06.pl6
index updated from file:///root/repo/api/v1/index
cat $root_dir/task.bash
$RAKUBIN -v
echo; echo; echo;
echo ".grep( { } )"
( time $RAKUBIN -e 'my $txt = slurp "/usr/share/dict/words"; for (1..1000) { my (@m) = $txt.grep( { m:i/ <!after i> e / } ) }' ) 2>&1
echo ===
echo "grep( *.contains )"
( time $RAKUBIN -e 'my $txt = slurp "/usr/share/dict/words"; for (1..1000) { my (@m) = $txt.grep( *.contains( /:i <!after i> e / ) ) }' ) 2>&1
echo ===
Welcome to ๐‘๐š๐ค๐ฎ๐๐จโ„ข v2021.05-43-g4887a169b.
Implementing the ๐‘๐š๐ค๐ฎโ„ข programming language v6.d.
Built on MoarVM version 2021.06.
.grep( { } )
real 0m4.312s
user 0m4.312s
sys 0m0.117s
===
grep( *.contains )
real 0m4.197s
user 0m4.192s
sys 0m0.165s
===
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment