-
-
Save felipernb/822579 to your computer and use it in GitHub Desktop.
mustang:~ fribeiro$ time `python -c "print(12345 ** 54321)" > /dev/null` | |
real 0m22.969s | |
user 0m22.531s | |
sys 0m0.059s | |
mustang:~ fribeiro$ time `ruby -e "puts 12345**54321" > /dev/null` | |
real 0m10.007s | |
user 0m9.943s | |
sys 0m0.022s | |
mustang:~ fribeiro$ time `php -r "echo bcpow(12345,54321);" > /dev/null` | |
real 0m4.191s | |
user 0m4.149s | |
sys 0m0.026s |
mustang:~ fribeiro$ php -r "echo bcpow(12345,54321);" > php.out | |
mustang:~ fribeiro$ ruby -e "puts 12345**54321" > ruby.out | |
mustang:~ fribeiro$ python -c "print(12345 ** 54321)" > python.out | |
mustang:~ fribeiro$ md5 *.out | |
MD5 (php.out) = b9e70261cddc56351f9e400ec008ca05 | |
MD5 (python.out) = 1089774eed3ff3f524a60d83d1747cf2 | |
MD5 (ruby.out) = 1089774eed3ff3f524a60d83d1747cf2 |
mustang:~ fribeiro$ file *.out | |
php.out: ASCII text, with no line terminators | |
python.out: ASCII text | |
ruby.out: ASCII text |
mustang:~ fribeiro$ ruby -e "puts 12345**54321" > ruby.out | |
mustang:~ fribeiro$ python -c "print(12345 ** 54321)" > python.out | |
mustang:~ fribeiro$ php -r "echo bcpow(12345,54321);" > php.out | |
mustang:~ fribeiro$ echo "" >> php.out | |
mustang:~ fribeiro$ md5 *.out | |
MD5 (php.out) = 1089774eed3ff3f524a60d83d1747cf2 | |
MD5 (python.out) = 1089774eed3ff3f524a60d83d1747cf2 | |
MD5 (ruby.out) = 1089774eed3ff3f524a60d83d1747cf2 |
Try using tr:
cat python.out | tr -s | md5sum
cat ruby.out | tr -s | md5sum
cat php.out | tr -s | md5sum
PHP echo doesn't add a line end char, adding it manually did the job:
$ echo "" >> php.out
Something is very wrong with your python. Took 22 seconds?!
renan@work:~ $ time `python -c "print(12345 ** 54321)" > /dev/null`
real 0m1.448s
user 0m1.434s
sys 0m0.011s
renan@work:~ $ time `ruby -e "puts 12345**54321" > /dev/null`
real 0m8.967s
user 0m8.951s
sys 0m0.011s
renan@work:~ $ time `php -r "echo bcpow(12345,54321);" > /dev/null`
real 0m2.881s
user 0m2.867s
sys 0m0.011s
jayson@jayson-ThinkPad-Edge:/Downloads/pypy-1.6/bin Python 2.7.1+/Downloads/pypy-1.6/bin Python 2.7.1+
$ python --version
Python 2.7.1+
jayson@jayson-ThinkPad-Edge:
$ time python -c "print(12345 ** 54321)" > /dev/null
real 0m2.122s
user 0m2.104s
sys 0m0.008s
jayson@jayson-ThinkPad-Edge:/Downloads/pypy-1.6/bin Python 2.7.1+/Downloads/pypy-1.6/bin Python 2.7.1+
$ ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
jayson@jayson-ThinkPad-Edge:
$ time ruby -e "puts 12345**54321" > /dev/null
real 0m0.747s
user 0m0.724s
sys 0m0.016s
jayson@jayson-ThinkPad-Edge:/Downloads/pypy-1.6/bin Python 2.7.1+/Downloads/pypy-1.6/bin Python 2.7.1+
$ php --version
PHP 5.3.6-13ubuntu3.2 with Suhosin-Patch (cli) (built: Oct 13 2011 23:09:42)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
jayson@jayson-ThinkPad-Edge:
$ time php -r "echo bcpow(12345,54321);" > /dev/null
real 0m4.223s
user 0m4.184s
sys 0m0.024s
Yeah, I don't know what happened at that time:
mustang:~ fribeiro$ time python -c "print(12345 ** 54321)" > /dev/null
real 0m2.046s
user 0m2.004s
sys 0m0.017s
mustang:~ fribeiro$ time ruby -e "puts 12345**54321" > /dev/null
real 0m1.011s
user 0m0.987s
sys 0m0.017s
mustang:~ fribeiro$ time php -r "echo bcpow(12345,54321);" > /dev/null
real 0m4.350s
user 0m4.176s
sys 0m0.031s
I just tested with pypy which is a python with jit, however for long it is slow for now.
/*
$ 6g p.go && 6l -o p p.6 && time ./p > /dev/null
real 0m1.882s
user 0m1.809s
sys 0m0.010s
*/
package main
import (
"fmt"
"big"
)
func main() {
x := big.NewInt(12345)
y := big.NewInt(54321)
x.Exp(x, y, nil)
fmt.Println(x)
}
Go after restart my laptop
real 0m1.760s
user 0m1.748s
sys 0m0.008s
golang
tony@hitman:~$ python --version && time python -c "print(12345 ** 54321)" > /dev/null
Python 2.7.1+
real 0m1.329s
user 0m1.320s
sys 0m0.010s
tony@hitman:$$
tony@hitman:
tony@hitman:~$ ruby1.9.1 --version && time ruby1.9.1 -e "puts 12345**54321" > /dev/null
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
real 0m0.803s
user 0m0.780s
sys 0m0.020s
tony@hitman:$$
tony@hitman:
tony@hitman:~$ php --version && time php -r "echo bcpow(12345,54321);" > /dev/null
PHP 5.3.5-1ubuntu7.3 with Suhosin-Patch (cli) (built: Oct 13 2011 22:20:48)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
real 0m3.884s
user 0m3.880s
sys 0m0.000s
Comparing with diff3 was "impossible", since the number is huge and all in one line.