Lang, env. |
1st run |
2nd run |
3rd run |
AVG |
Ratio |
PHP 5.4.4 |
205 554 ms |
194 159 ms |
179 753 ms |
193 155 ms |
189,99x |
Python 2.7.3 |
200 830 ms |
191 170 ms |
193 650 ms |
195 217 ms |
192,02x |
Python 3.2.3 |
410 520 ms |
396 540 ms |
395 160 ms |
400 740 ms |
394,17x |
Java 1.8.0-ea |
2 378 ms |
2 362 ms |
2 391 ms |
2 377 ms |
2,34x |
C++ (G++ 4.6.3) |
1 020 ms |
1 020 ms |
1 010 ms |
1 017 ms |
1,00x |
https://github.com/MikeMirzayanov/binary-heap-benchmark
N = 1 000 000
binary-heap-benchmark/php $ php –version
PHP 5.4.4-14+deb7u7 (cli) (built: Dec 13 2013 02:49:06)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
binary-heap-benchmark/php $ php heap.php
Done in 205554
binary-heap-benchmark/php $ php heap.php
Done in 194159
binary-heap-benchmark/php $ php heap.php
Done in 179753
binary-heap-benchmark/python2 $ python2 –version
Python 2.7.3
binary-heap-benchmark/python2 $ python2 heap.py
Done in 200830.000000
binary-heap-benchmark/python2 $ python2 heap.py
Done in 191170.000000
binary-heap-benchmark/python2 $ python2 heap.py
Done in 193650.000000
binary-heap-benchmark/python3 $ python3 –version
Python 3.2.3
binary-heap-benchmark/python3 $ python3 heap.py
Done in 410520.000000
binary-heap-benchmark/python3 $ python3 heap.py
Done in 396540.000000
binary-heap-benchmark/python3 $ python3 heap.py
Done in 395160.000000
binary-heap-benchmark/java $ java -version
java version “1.8.0-ea”
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)
binary-heap-benchmark/java $ java Heap
Done in 2378
binary-heap-benchmark/java $ java Heap
Done in 2362
binary-heap-benchmark/java $ java Heap
Done in 2391
binary-heap-benchmark/cpp $ g++ –version
g++ (Debian 4.6.3-14+rpi1) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
binary-heap-benchmark/cpp $ g++ -O2 -o heap heap.cpp
binary-heap-benchmark/cpp $ chmod u+x heap
binary-heap-benchmark/cpp $ ./heap
Done in 1020
binary-heap-benchmark/cpp $ ./heap
Done in 1020
binary-heap-benchmark/cpp $ ./heap
Done in 1010
binary-heap-benchmark/cpp $ g++ -O0 -o heap heap.cpp
binary-heap-benchmark/cpp $ ./heap
Done in -144
binary-heap-benchmark/cpp $ time ./heap
Done in -94
real 0m4.264s
user 0m4.210s
sys 0m0.000s
binary-heap-benchmark/cpp $ time ./heap
Done in -144
real 0m4.213s
user 0m4.130s
sys 0m0.020s
binary-heap-benchmark/cpp $ time ./heap
Done in -144
real 0m4.214s
user 0m4.100s
sys 0m0.060s
binary-heap-benchmark/cpp $ g++ -O1 -o heap heap.cpp
binary-heap-benchmark/cpp $ ./heap
Done in 1030
binary-heap-benchmark/cpp $ ./heap
Done in 1030
binary-heap-benchmark/cpp $ ./heap
Done in 1030
|