![]() |
Projects Publications Resume Links Contact About Youtube Donate |
|
A | B | C | D | E | F | G | H | I | |
---|---|---|---|---|---|---|---|---|---|
1 | language | compiler / interpreter | exec type | source (B) | source (lines) | exec (B) | exec time (s) | resident (MB) | idle cpu (%) |
2 | C | clang | native | 768 | 24 | 8714 | 206.1 | 764 | 86 |
3 | C++ | clang++ | native | 761 | 24 | 13598 | 206.2 | 765 | 86 |
4 | C | gcc | native | 768 | 24 | 8658 | 225.9 | 764 | 86 |
5 | C++ | g++ | native | 761 | 24 | 13363 | 226.4 | 765 | 86 |
6 | Java | gcj | native | 799 | 21 | 15382 | 243.6 | 794 | 86 |
7 | Ada | gnat | native | 1373 | 37 | 59509 | 289.9 | 766 | 86 |
8 | Java | javac | vm | 799 | 21 | 1030 | 363.0 | 793 | 74 |
9 | Cython | python & gcc | vm & native | 964 | 31 | 56249 | 382.4 | 769 | 86 |
10 | Pascal | fpc | native | 822 | 31 | 370624 | 952.1 | 763 | 86 |
11 | Go | go | native | 795 | 29 | 1828522 | 1004.9 | 765 | 86 |
12 | Javascript | node | script | 620 | 20 | 620 | 1678.6 | 786 | 86 |
13 | Python | python & gcc | vm & native | 778 | 26 | 68642 | 12430 | 2970 | 86 |
14 | Ruby | ruby | script | 512 | 25 | 512 | 15410 | 1464 | 86 |
15 | Lua | lua | script | 449 | 22 | 449 | 16990 | 2002 | 86 |
16 | PHP | php | script | 616 | 25 | 616 | 19195 | 14132 | 86 |
17 | Python | python | vm | 609 | 23 | 893 | 24970 | 2970 | 86 |
18 | Perl | perl | script | 563 | 24 | 563 | 27010 | 5939 | 86 |
19 | NumPy | python & gcc | vm & native | 892 | 30 | 77661 | 36605 | 780 | 86 |
20 | NumPy | python | vm | 725 | 27 | 953 | 53819 | 780 | 86 |
#include <stdio.h> #include <malloc.h> #include <stdlib.h> int main(int argc, char **argv) { int element = 0; int iteration = 0; int iterations = 0; int innerloop = 0; double sum = 0.0; int array_length = 100000000; double *array = (double*)malloc(array_length * sizeof(double)); if (argc > 1) iterations = atoi(argv[1]); printf("iterations %d\n", iterations); for (element = 0; element < array_length; element++) array[element] = element; for (iteration = 0; iteration < iterations; iteration++) for (innerloop = 0; innerloop < 1000000000; innerloop++) sum += array[(iteration + innerloop) % array_length]; printf("sum %E\n", sum); free(array); array = NULL; return 0; }
#include <iostream> #include <cstdlib> using namespace std; int main(int argc, char **argv) { int element = 0; int iteration = 0; int iterations = 0; int innerloop = 0; double sum = 0; int array_length = 100000000; double *array = new double[array_length]; if (argc > 1) iterations = atoi(argv[1]); cout << "iterations " << iterations << endl;; for (element = 0; element < array_length; element++) array[element] = element; for (iteration = 0; iteration < iterations; iteration++) for (innerloop = 0; innerloop < 1000000000; innerloop++) sum += array[(iteration + innerloop) % array_length]; cout << "sum " << sum << endl; delete array; array = NULL; return 0; }
public class test { public static void main(String[] args) { int element = 0; int iteration = 0; int iterations = 0; int innerloop = 0; double sum = 0.0; int array_length = 100000000; double[] array = new double[array_length]; if (args.length > 0) iterations = Integer.parseInt(args[0]); System.out.println("iterations " + iterations); for (element = 0; element < array_length; element++) array[element] = element; for (iteration = 0; iteration < iterations; iteration++) for (innerloop = 0; innerloop < 1000000000; innerloop++) sum += array[(iteration + innerloop) % array_length]; System.out.println("sum " + sum); array = null; } }
with Ada.Text_IO, Ada.Command_Line, Ada.Unchecked_Deallocation; use Ada.Text_IO, Ada.Command_Line; procedure test is element : Integer := 0; iteration : Integer := 0; iterations : Integer := 0; innerloop : Integer := 0; sum : Standard.Long_Float := 0.0; array_length : Integer := 100000000; type vector is array (0..array_length) of Standard.Long_Float; type vector_access is access vector; procedure free_vector is new Ada.Unchecked_Deallocation (Object => vector, Name => vector_access); begin declare test_array : vector_access := new vector; begin if Argument_Count > 0 then iterations := Integer'Value(Argument(1)); end if; Put_Line("iterations " & Integer'Image(iterations)); while element < array_length loop test_array(element) := Standard.Long_Float(element); element := element + 1; end loop; while iteration < iterations loop innerloop := 0; while innerloop < 1000000000 loop sum := sum + test_array((iteration + innerloop) mod array_length); innerloop := innerloop + 1; end loop; iteration := iteration + 1; end loop; Put_Line("sum " & Standard.Long_Float'Image(sum)); free_vector(test_array); end; end test;
package main import "os" import "fmt" import "strconv" func main() { var ( element int = 0 iteration int = 0 iterations int = 0 innerloop int = 0 sum float64 = 0.0 array_length int = 100000000 array []float64 = make([]float64, array_length) ) if len(os.Args) > 1 { iterations,_ = strconv.Atoi(os.Args[1]) } fmt.Printf("iterations %d\n", iterations) for element = 0; element < array_length; element++ { array[element] = float64(element) } for iteration = 0; iteration < iterations; iteration++ { for innerloop = 0; innerloop < 1000000000; innerloop++ { sum += array[(iteration + innerloop) % array_length] } } fmt.Printf("sum %E\n", sum) array = nil }
import sys import test_python iterations = 0 if len(sys.argv) > 1: iterations = int(sys.argv[1]) test_python.test_python(iterations)
import sys def test_python(iterations): element = 0 iteration = 0 innerloop = 0 total = float(0.0) array_length = 100000000 array = [i for i in range(array_length)] print 'iterations', iterations while iteration < iterations: innerloop = 0 while innerloop < 1000000000: total += array[(iteration + innerloop) % array_length]; innerloop += 1 iteration += 1 print 'sum', total del array
import sys import test_python_cython iterations = 0 if len(sys.argv) > 1: iterations = int(sys.argv[1]) test_python_cython.test_python(iterations)
import sys def test_python(iterations): element = 0 iteration = 0 innerloop = 0 total = float(0.0) array_length = 100000000 array = [i for i in range(array_length)] print 'iterations', iterations while iteration < iterations: innerloop = 0 while innerloop < 1000000000: total += array[(iteration + innerloop) % array_length]; innerloop += 1 iteration += 1 print 'sum', total del array
from distutils.core import setup from Cython.Build import cythonize setup(name = 'test python cython', ext_modules = cythonize("test_python_cython.pyx"))
import sys import test_numpy iterations = 0 if len(sys.argv) > 1: iterations = int(sys.argv[1]) test_numpy.test_python(iterations)
import numpy import sys def test_python(iterations): element = 0 iteration = 0 innerloop = 0 total = numpy.float64(0.0) array_length = 100000000 array = numpy.zeros(array_length, numpy.float64) print 'iterations', iterations while element < array_length: array[element] = element element += 1 while iteration < iterations: innerloop = 0 while innerloop < 1000000000: total += array[(iteration + innerloop) % array_length]; innerloop += 1 iteration += 1 print 'sum', total del array
import sys import test_numpy_cython iterations = 0 if len(sys.argv) > 1: iterations = int(sys.argv[1]) test_numpy_cython.test_python(iterations)
import numpy import sys def test_python(iterations): element = 0 iteration = 0 innerloop = 0 total = numpy.float64(0.0) array_length = 100000000 array = numpy.zeros(array_length, numpy.float64) print 'iterations', iterations while element < array_length: array[element] = element element += 1 while iteration < iterations: innerloop = 0 while innerloop < 1000000000: total += array[(iteration + innerloop) % array_length]; innerloop += 1 iteration += 1 print 'sum', total del array
from distutils.core import setup from Cython.Build import cythonize setup(name = 'test numpy cython', ext_modules = cythonize("test_numpy_cython.pyx"))
import sys import test_cython iterations = 0 if len(sys.argv) > 1: iterations = int(sys.argv[1]) test_cython.test_cython(iterations)
import sys from libc.stdlib cimport malloc, free def test_cython(iterations): cdef int element = 0 cdef int iteration = 0 cdef int innerloop = 0 cdef double total = 0.0 cdef int array_length = 100000000 cdef double *array = <double *>malloc(array_length * sizeof(double)) print 'iterations', iterations while element < array_length: array[element] = element element += 1 while iteration < iterations: innerloop = 0 while innerloop < 1000000000: total += array[(iteration + innerloop) % array_length]; innerloop += 1 iteration += 1 print 'sum', total free(array) array = NULL
from distutils.core import setup from Cython.Build import cythonize setup(name = 'test cython', ext_modules = cythonize("test_cython.pyx"))
#!/usr/bin/node --max-old-space-size=4096 var element = 0; var iteration = 0; var iterations = 0; var innerloop = 0; var sum = 0.0; var array_length = 100000000; var array = new Array(array_length); var argc = process.argv.length if (argc > 2) iterations = process.argv[2]; console.log("iterations " + iterations); for (element = 0; element < array_length; element++) array[element] = element; for (iteration = 0; iteration < iterations; iteration++) for (innerloop = 0; innerloop < 1000000000; innerloop++) sum += array[(iteration + innerloop) % array_length]; console.log("sum " + sum); array = 0
#!/usr/bin/perl $element = 0.0; $iteration = 0; $iterations = 0; $innerloop = 0; $sum = 0.0; $array_length = 100000000; @array = []; $argc = @ARGV; if ($argc > 0) { $iterations = $ARGV[0]; } print("iterations $iterations\n"); for ($element = 0.0; $element < 100000000.0; $element++) { $array[$element] = $element; } for ($iteration = 0; $iteration < $iterations; $iteration++) { for ($innerloop = 0; $innerloop < 1000000000; $innerloop++) { $sum += $array[($iteration + $innerloop) % $array_length]; } } print("sum $sum\n"); @array = [];
#!/usr/bin/ruby require 'matrix' element = 0.0 iteration = 0 iterations = 0 innerloop = 0 sum = 0.0 array_length = 100000000 array = Array.new(array_length) {0.0} vector = [array] if ARGV[0] iterations = ARGV[0].to_i end puts "iterations #{iterations}" for element in 0..array_length-1 vector[element] = element end for iteration in 0..iterations-1 for innerloop in 0..1000000000-1 sum = sum + vector[(iteration + innerloop) % array_length]; end end printf("sum %E\n", sum); array = nil
program testpascal; uses sysutils; type vector = array of double; var element : longint; iteration : longint; iterations : longint; innerloop : longint; sum : double; array_length : longint; my_array : vector; begin element := 0; iteration := 0; iterations := 0; innerloop := 0; sum := 0.0; array_length := 100000000; setlength(my_array, array_length); if paramcount > 0 then iterations := strtoint(paramstr(1)); writeln('iterations ', iterations); for element := 0 to array_length-1 do my_array[element] := element; for iteration := 0 to iterations-1 do for innerloop := 0 to 1000000000-1 do sum := sum + my_array[(iteration + innerloop) mod array_length]; writeln('sum ', sum); my_array := nil; end.
#!/usr/bin/lua element = 0 iteration = 0 iterations = 0 innerloop = 0 sum = 0 array_length = 100000000 array = {} if #arg > 0 then iterations = tonumber(arg[1]) end print("iterations ", iterations) for element=0, array_length-1 do array[element] = element end for iteration=0, iterations-1 do for innerloop=0, 1000000000-1 do sum = sum + array[((iteration + innerloop) % array_length)] end end print("sum ", sum) array = nil
#!/usr/bin/php <?php ini_set('memory_limit', '-1'); $element = 0; $iteration = 0; $iterations = 0; $innerloop = 0; $sum = 0.0; $array_length = 100000000; $array[] = 0; if ( $argc > 1 ) { $iterations = $argv[1]; } fwrite(STDOUT, "iterations ". $iterations . "\n"); for ($element = 1; $element < $array_length; $element++) { $array[] = $element; } for ($iteration = 0; $iteration < $iterations; $iteration++) { for ($innerloop = 0; $innerloop < 1000000000; $innerloop++) { $sum = $sum + $array[($iteration + $innerloop) % $array_length]; } } fwrite(STDOUT, "sum ". $sum . "\n"); $array = 0; ?>
all:\ test-c-gcc test-c-clang\ test-cpp-g++ test-cpp-clang++\ test-java test.class\ test-go\ test-ada\ test_python.pyc test_python_cython.so\ test_numpy.pyc test_numpy_cython.so\ test_cython.so\ test-pascal test-c-gcc: test.c gcc -O3 -o test-c-gcc test.c test-c-clang: test.c clang -O3 -o test-c-clang test.c test-cpp-g++: test.cpp g++ -O3 -o test-cpp-g++ test.cpp test-cpp-clang++: test.cpp clang++ -O3 -o test-cpp-clang++ test.cpp test-java: test.java gcj -O3 --main=test -o test-java test.java test.class: test.java javac test.java test-go: test.go go build -o test-go test.go test-ada: test.adb gnatmake -O3 -o test-ada test.adb test_python.pyc: test_python.py test-python.py python -m py_compile test_python.py python -m py_compile test-python.py test_python_cython.so: test_python_cython.pyx setup_python_cython.py test-python-cython.py python setup_python_cython.py build_ext --inplace python -m py_compile test-python-cython.py test_numpy.pyc: test_numpy.py test-numpy.py python -m py_compile test_numpy.py python -m py_compile test-numpy.py test_numpy_cython.so: test_numpy_cython.pyx setup_numpy_cython.py test-numpy-cython.py python setup_numpy_cython.py build_ext --inplace python -m py_compile test-numpy-cython.py test_cython.so: test_cython.pyx setup_cython.py test-cython.py python setup_cython.py build_ext --inplace python -m py_compile test-cython.py test-pascal: test.pas fpc -O3 -otest-pascal test.pas clean: rm -f *.o *.so *.pyc rm -f test-c-gcc test-c-clang test-cpp-g++ test-cpp-clang++ rm -f test-java test.class test-go test-ada test.ali rm -rf build test_python_cython.c test_numpy_cython.c test_cython.c rm -f test-pascal run_test: all echo "-------------------------------------" time -p ./test-c-gcc 100 time -p ./test-c-clang 100 time -p ./test-cpp-g++ 100 time -p ./test-cpp-clang++ 100 time -p ./test-java 100 time -p java test 100 time -p ./test-ada 100 time -p ./test-go 100 echo "Multiply the test-python.pyc time by 100 for comparison." time -p python test-python.pyc 1 echo "Multiply the test-python-cython.pyc time by 100 for comparison." time -p python test-python-cython.pyc 1 echo "Multiply the test-numpy.pyc time by 100 for comparison." time -p python test-numpy.pyc 1 echo "Multiply the test-numpy-cython.pyc time by 100 for comparison." time -p python test-numpy-cython.pyc 1 time -p python test-cython.pyc 100 time -p ./test.js 100 echo "Multiply the test.pl time by 100 for comparison." time -p ./test.pl 1 echo "Multiply the test.rb time by 100 for comparison." time -p ./test.rb 1 time -p ./test-pascal 100 echo "Multiply the test.lua time by 100 for comparison." time -p ./test.lua 1 echo "Multiply the test.php time by 100 for comparison." time -p ./test.php 1