Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- PYTHON 2.7.8 --
- real 0m1.020s
- real 0m1.046s
- real 0m1.248s
- real 0m1.209s
- real 0m1.228s
- real 0m1.136s
- real 0m1.146s
- real 0m1.197s
- real 0m1.200s
- real 0m1.181s
- real 0m1.166s
- -- PYTHON 3.4.1 --
- real 0m1.088s
- real 0m1.080s
- real 0m1.074s
- real 0m1.086s
- real 0m1.139s
- real 0m1.113s
- real 0m1.069s
- real 0m1.076s
- real 0m1.056s
- real 0m1.075s
- real 0m1.326s
- -- RUBY 2.1.3p242 --
- real 0m0.952s
- real 0m0.950s
- real 0m1.113s
- real 0m1.079s
- real 0m1.073s
- real 0m1.107s
- real 0m1.087s
- real 0m1.128s
- real 0m1.075s
- real 0m1.081s
- real 0m1.092s
- -- PHP 5.6.1 --
- real 0m1.241s
- real 0m1.239s
- real 0m1.351s
- real 0m1.378s
- real 0m1.345s
- real 0m1.445s
- real 0m1.372s
- real 0m1.401s
- real 0m1.567s
- real 0m1.352s
- real 0m1.404s
- -- HHVM 3.7.3 --
- real 0m1.509s
- real 0m1.525s
- real 0m1.569s
- real 0m1.582s
- real 0m1.540s
- real 0m1.552s
- real 0m1.567s
- real 0m1.579s
- real 0m1.576s
- real 0m1.553s
- real 0m1.525s
- -- Java 1.8.0_45 --
- real 0m0.346s
- real 0m0.340s
- real 0m0.338s
- real 0m0.339s
- real 0m0.337s
- real 0m0.337s
- real 0m0.341s
- real 0m0.340s
- real 0m0.337s
- real 0m0.333s
- real 0m0.341s
- -- Scala 2.11.7 --
- real 0m0.499s
- real 0m0.504s
- real 0m0.508s
- real 0m0.503s
- real 0m0.508s
- real 0m0.506s
- real 0m0.515s
- real 0m0.508s
- real 0m0.502s
- real 0m0.502s
- real 0m0.507s
- -- Node.js 0.12.4 --
- real 0m1.851s
- real 0m1.872s
- real 0m1.964s
- real 0m1.949s
- real 0m1.931s
- real 0m1.942s
- real 0m1.966s
- real 0m1.953s
- real 0m1.972s
- real 0m2.088s
- real 0m1.967s
- -- Io.js 2.3.1 --
- real 0m1.973s
- real 0m1.758s
- real 0m1.823s
- real 0m1.766s
- real 0m1.759s
- real 0m1.768s
- real 0m1.716s
- real 0m1.786s
- real 0m1.803s
- real 0m1.758s
- real 0m1.737s
- -- SOURCES --
- $ cat test.py
- #!/usr/bin/env python
- f = open('python.txt', 'w')
- for i in range(1, 1000000):
- f.write ("%d\t%d\n" % (i, i**2))
- f.close()
- $ cat test.py3
- #!/usr/bin/env python3
- f = open('python.txt', 'w')
- for i in range(1, 1000000):
- f.write ("%d\t%d\n" % (i, i**2))
- f.close()
- $ cat test.rb
- #!/usr/bin/env ruby
- f = open('ruby.txt', 'w')
- for i in 1...1000000
- f.puts sprintf("%d\t%d", i, i**2)
- end
- f.close
- $ cat test.php
- #!/usr/bin/env php
- <?php
- $f = fopen('php.txt', 'w');
- for ($i = 0; $i < 1000000; $i++) {
- fwrite($f, $i."\t".$i**2);
- }
- fclose($f);
- $ cat test.hh
- <?php
- $f = fopen('hack.txt', 'w');
- for ($i = 0; $i < 1000000; $i++) {
- fwrite($f, $i."\t".$i**2);
- }
- fclose($f);
- $ cat BenchmarkingTestCaseLongNamedClassBecauseJavaIsVerboseForTheWin.java
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- public class BenchmarkingTestCaseLongNamedClassBecauseJavaIsVerboseForTheWin {
- public static void main(String[] args)
- {
- FileWriter fw = null;
- try {
- File file = new File("java.txt");
- fw = new FileWriter(file, true);
- for (long i = 0; i < 1000000; i++) {
- fw.write(String.valueOf(i) + "\t" + String.valueOf(Math.pow(i, 2))); // String.format() is very slow
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- } finally {
- if (fw != null) {
- try {
- fw.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- }
- }
- }
- $ cat test.scala
- import java.io._
- object Test {
- def main(args: Array[String]):Unit = {
- val fw = new FileWriter("scala.txt")
- var i = 0;
- while (i < 1000000) {
- fw.write( String.valueOf(i) + "\t" + String.valueOf(Math.pow(i,2)) )
- i += 1;
- }
- fw.close
- }
- }
- $ cat test.js
- var fs = require('fs')
- var fd = fs.openSync('node.txt', 'w')
- for (var i = 0; i < 1000000; i++) {
- fs.writeSync(fd, i+"\t"+Math.pow(i,2))
- }
- fs.closeSync(fd)
- -- BENCHMARK SCRIPT --
- $ cat bench.sh
- #!/bin/bash
- echo "-- PYTHON 2.7.8 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time ./test.py) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- PYTHON 3.4.1 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time ./test.py3) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- RUBY 2.1.3p242 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time ./test.rb) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- PHP 5.6.1 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time ./test.php) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- HHVM 3.7.3 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time hhvm -v Eval.Jit=0 -v Eval.JitProfileInterpRequests=0 test.hh) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- Java 1.8.0_45 --"
- javac BenchmarkingTestCaseLongNamedClassBecauseJavaIsVerboseForTheWin.java
- for ((x = 0 ; x <= 10 ; x++)); do
- (time java BenchmarkingTestCaseLongNamedClassBecauseJavaIsVerboseForTheWin) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- Scala 2.11.7 --"
- scalac test.scala
- for ((x = 0 ; x <= 10 ; x++)); do
- (time scala Test) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- Node.js 0.12.4 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time node test.js) 2>&1 > /dev/null | grep real
- done
- echo ""
- echo "-- Io.js 2.3.1 --"
- for ((x = 0 ; x <= 10 ; x++)); do
- (time iojs test.js) 2>&1 > /dev/null | grep real
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement