# HG changeset patch # User Jaroslav Tulach # Date 1355384632 -3600 # Node ID fc52cbbcbeb917a4d437f1cbd7276bffa6546c07 # Parent f36b3c273de6e5f94720d400740b671493f52280# Parent 1a3f102e5ea5cf0bc26927b269293f8497eae72c Merging benchmarks branch into trunk, it seems to be usable. Just run mvn test -Dbck2brwsr.runBenchmarks.browsers=firefox,google-chrome etc. diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/jsTestDriver.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/jsTestDriver.conf Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,5 @@ +server: http://localhost:9876 + +load: + - target/classes/org/apidesign/benchmark/matrixmul/*.js + diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/nbactions.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/nbactions.xml Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,29 @@ + + + + + run + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/pom.xml Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,111 @@ + + + 4.0.0 + + org.apidesign.bck2brwsr + matrix.multiplication + 0.3-SNAPSHOT + jar + + Matrix multiplication + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + + org.apidesign.bck2brwsr + mojo + 0.3-SNAPSHOT + + + + j2js + + + + + + + + + + + run-benchmarks + + bck2brwsr.runBenchmarks.browsers + + + + + + + com.googlecode.jstd-maven-plugin + jstd-maven-plugin + 1.3.2.5 + + 9876 + ${bck2brwsr.runBenchmarks.browsers} + 720 + all + jsTestDriver.conf + true + ${basedir}/target/testOutput + + + + + run-tests + + test + + + + + + + + + + + + + org.apidesign.bck2brwsr + emul + 0.3-SNAPSHOT + + + com.googlecode.jstd-maven-plugin + jstd-maven-plugin + 1.3.2.5 + test + + + + + + jstd-maven-plugin google code repo + http://jstd-maven-plugin.googlecode.com/svn/maven2 + + + + + jstd-maven-plugin google code repo + http://jstd-maven-plugin.googlecode.com/svn/maven2 + + + + diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Main.java Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,42 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.benchmark.matrixmul; + +public class Main { + + public static final int ITERATION_COUNT = 100000; + + public static void main(String[] args) { + Matrix m1 = new Matrix(5); + Matrix m2 = new Matrix(5); + + m1.generateData(); + m2.generateData(); + + //m1.printOn(System.out); + //System.out.println("x"); + //m2.printOn(System.out); + + for (int i = 0; i < ITERATION_COUNT; i++) { + m1.multiply(m2); + } + + //System.out.println("="); + //m1.printOn(System.out); + } +} diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Matrix.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Matrix.java Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,81 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.benchmark.matrixmul; + +//import java.io.PrintStream; +//import java.util.Random; + +public class Matrix { + + private final int rank; + private float data[][]; + + public Matrix(int r) { + rank = r; + data = new float[r][r]; + } + + public void setElement(int i, int j, float value) { + data[i][j] = value; + } + public float getElement(int i, int j) { + return data[i][j]; + } + + public void generateData() { + //final Random rand = new Random(); + //final int x = 10; + for (int i = 0; i < rank; i++) { + for (int j = 0; j < rank; j++) { + data[i][j] = i + j; + } + } + } + + public Matrix multiply(Matrix m) { + if (rank != m.rank) { + throw new IllegalArgumentException("Rank doesn't match"); + } + + final float res[][] = new float[rank][rank]; + for (int i = 0; i < rank; i++) { + for (int j = 0; j < rank; j++) { + float ij = 0; + for (int q = 0; q < rank; q++) { + ij += data[i][q] * m.data[q][j]; + } + res[i][j] = ij; + } + } + data = res; + + return this; + } + + /* + public void printOn(PrintStream s) { + for (int i = 0; i < rank; i++) { + for (int j = 0; j < rank; j++) { + s.printf("%f ", data[i][j]); + } + s.println(); + } + } + */ + +} diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/matrix-multiplication/src/main/resources/org/apidesign/benchmark/matrixmul/multiplication-test.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/matrix-multiplication/src/main/resources/org/apidesign/benchmark/matrixmul/multiplication-test.js Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,25 @@ +/* + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +MatrixTest = TestCase("MatrixTest"); + + +MatrixTest.prototype.testMultiplication = function() { + var vm = new bck2brwsr(); + var x = vm.loadClass("org.apidesign.benchmark.matrixmul.Main"); + x.main__V_3Ljava_lang_String_2(null); +}; diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/pom.xml Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,17 @@ + + + 4.0.0 + + bck2brwsr + org.apidesign + 0.3-SNAPSHOT + + org.apidesign.bck2brwsr + benchmarks + 0.3-SNAPSHOT + pom + Performance benchmarks + + matrix-multiplication + + diff -r f36b3c273de6 -r fc52cbbcbeb9 benchmarks/run-firefox.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/benchmarks/run-firefox.sh Thu Dec 13 08:43:52 2012 +0100 @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Back 2 Browser Bytecode Translator +# Copyright (C) 2012 Jaroslav Tulach +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. Look for COPYING file in the top folder. +# If not, see http://opensource.org/licenses/GPL-2.0. +# + +/usr/bin/firefox --display=`echo $DISPLAY` "$@" diff -r f36b3c273de6 -r fc52cbbcbeb9 pom.xml --- a/pom.xml Wed Dec 12 09:09:42 2012 +0100 +++ b/pom.xml Thu Dec 13 08:43:52 2012 +0100 @@ -13,6 +13,7 @@ mojo javaquery javap + benchmarks