Created
January 25, 2016 00:58
-
-
Save yujikosuga/3ec7e8e310391179d0f1 to your computer and use it in GitHub Desktop.
Computation Time of ^(a+)+$ by Programming Language
This file contains hidden or 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
# Perl Computation Time of ^(a+)+$ | |
$ time perl -e 'print (("a"x100 . "b") =~ /^(a+)+$/)' | |
real 0m0.010s | |
user 0m0.003s | |
sys 0m0.004s | |
$ time perl -e 'print (("a"x1000 . "b") =~ /^(a+)+$/)' | |
real 0m0.011s | |
user 0m0.004s | |
sys 0m0.005s | |
$ time perl -e 'print (("a"x10000 . "b") =~ /^(a+)+$/)' | |
real 0m0.010s | |
user 0m0.005s | |
sys 0m0.004s | |
$ time perl -e 'print (("a"x100000 . "b") =~ /^(a+)+$/)' | |
real 0m0.027s | |
user 0m0.021s | |
sys 0m0.004s | |
$ time perl -e 'print (("a"x1000000 . "b") =~ /^(a+)+$/)' | |
real 0m0.188s | |
user 0m0.179s | |
sys 0m0.007s | |
$ time perl -e 'print (("a"x10000000 . "b") =~ /^(a+)+$/)' | |
real 0m1.725s | |
user 0m1.705s | |
sys 0m0.016s | |
$ time perl -e 'print (("a"x100000000 . "b") =~ /^(a+)+$/)' | |
real 0m17.504s | |
user 0m17.209s | |
sys 0m0.181s |
This file contains hidden or 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
# Python Computation Time of ^(a+)+$ | |
$ time python -c 'import re;re.match(r"^(a+)+$","a"*1+"b")' | |
real 0m0.024s | |
user 0m0.012s | |
sys 0m0.010s | |
$ time python -c 'import re;re.match(r"^(a+)+$","a"*10+"b")' | |
real 0m0.023s | |
user 0m0.012s | |
sys 0m0.009s | |
$ time python -c 'import re;re.match(r"^(a+)+$","a"*100+"b")' | |
... Very long time. ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment