-
-
Save stqism/ccc9c5a932a6c45e5078 to your computer and use it in GitHub Desktop.
Holy fuck Python is slow
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
count = 0 | |
while (count < 1000000000): | |
count = count + 1 |
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
fn main() { | |
let mut count = 0; | |
while count < 1000000000 { | |
count += 1; | |
} | |
} |
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
sean@Soyuz:~/rust$ time python 1.py (Python optimizations only speed up loading) | |
real 7m10.859s | |
user 7m2.517s | |
sys 0m4.206s | |
sean@Soyuz:~/rust$ time ./1 (With -O) | |
real 0m0.006s | |
user 0m0.002s | |
sys 0m0.005s | |
4 seconds without optimizations. | |
Pretty sure rust is cheating, turning 10 million in to 10,000,000,000,000,000 takes 10 ms to run. |
$ cat loop.c
main()
{
int x;
for (x = 0; x < 1000000000; x++) {
}
}
$ gcc -O3 loop.c
$ time ./a.out
real 0m0.001s
user 0m0.000s
sys 0m0.000s
$ cat loop.pl
use strict;
use warnings;
for (my $i = 0; $i < 1000000000; $i++) {
}
$ time perl loop.pl
real 0m30.078s
user 0m30.092s
sys 0m0.000s
$ cat loop.go
package main
func main() {
for i := 0; i < 1000000000; i++ {
}
}
$ go build loop.go
$ time ./loop
real 0m0.333s
user 0m0.332s
sys 0m0.000s
microbenchmarks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python is fast and doesn't cheat!