|
GCCGo / Go slow "big" package discussion from some time ago |
|
Back at that point, Go's 6g compiler had an implementation of the big package with assembler implementations that hadn't been ported to GCCGo. |
|
https://groups.google.com/forum/?fromgroups=#!searchin/golang-nuts/Is$20Go$20%22big%22$20package$20slow?$20is$20Go$20slow?/golang-nuts/ChpHRdGU8ks/gyhBjheZmSEJ |
|
|
|
Neither Java, PyPy, CPython, Go or GCCGo use GMP |
|
|
|
CPython and PyPy can "cheat" on small integers as they use normal ints until big integers are required. |
|
To make the comparison only over bigints, I've ensured all integers are > 64 bits. |
|
|
|
To execute the test yourself, just run |
|
|
|
make |
|
|
|
|
|
Results: |
|
|
|
smerity@pegasus:~/Coding/goxercise$ time go run factors.go |
|
496968652506233122158689 |
|
|
|
real 0m3.503s |
|
user 0m3.516s |
|
sys 0m0.056s |
|
|
|
smerity@pegasus:~/Coding/goxercise$ gccgo -O3 factors.go && time ./a.out |
|
496968652506233122158689 |
|
|
|
real 0m8.453s |
|
user 0m8.421s |
|
sys 0m0.004s |
|
|
|
smerity@pegasus:~/Coding/goxercise$ time python factors.py |
|
496968652506233122158689 |
|
|
|
real 0m1.899s |
|
user 0m1.880s |
|
sys 0m0.012s |
|
|
|
smerity@pegasus:~/Coding/goxercise$ time ~/Coding/Reference/pypy-2.0-beta1/bin/pypy factors.py |
|
496968652506233122158689 |
|
|
|
real 0m1.169s |
|
user 0m1.148s |
|
sys 0m0.016s |
|
|
|
smerity@pegasus:~/Coding/goxercise$ time java Factors |
|
496968652506233122158689 |
|
|
|
real 0m1.614s |
|
user 0m1.656s |
|
sys 0m0.092s |
|
|
|
|
|
Results 2017-06: |
|
|
|
+ go version |
|
go version go1.8.3 linux/amd64 |
|
+ go build factors.go |
|
+ ./factors |
|
496968652506233122158689 |
|
|
|
real 0m2.377s |
|
user 0m2.360s |
|
sys 0m0.003s |
|
+ gccgo --version |
|
gccgo (Gentoo 6.3.0 p1.0) 6.3.0 |
|
Copyright (C) 2016 Free Software Foundation, Inc. |
|
Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es |
|
gibt KEINE Garantie; auch nicht für MARKTGÄNGIGKEIT oder FÜR SPEZIELLE ZWECKE. |
|
|
|
+ gccgo -O3 factors.go |
|
+ ./a.out |
|
496968652506233122158689 |
|
|
|
real 0m8.496s |
|
user 0m8.630s |
|
sys 0m0.293s |
|
+ python2 --version |
|
Python 2.7.12 |
|
+ python2 factors.py |
|
496968652506233122158689 |
|
|
|
real 0m3.513s |
|
user 0m3.047s |
|
sys 0m0.000s |
|
+ ./pypy --version |
|
Python 2.7.13 (c925e73810367cd960a32592dd7f728f436c125c, Jun 08 2017, 19:14:08) |
|
[PyPy 5.8.0 with GCC 6.3.0] |
|
+ ./pypy factors.py |
|
496968652506233122158689 |
|
|
|
real 0m1.732s |
|
user 0m1.717s |
|
sys 0m0.017s |
|
+ java -version |
|
java version "1.7.0_121" |
|
OpenJDK Runtime Environment (IcedTea 2.6.8) (Gentoo icedtea-7.2.6.8) |
|
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode) |
|
+ javac Factors.java |
|
+ java Factors |
|
496968652506233122158689 |
|
|
|
real 0m2.008s |
|
user 0m1.970s |
|
sys 0m0.147s |