first version of benchmarks benchmarks
authorMartin Soch <Martin.Soch@oracle.com>
Wed, 05 Dec 2012 11:18:09 +0100
branchbenchmarks
changeset 268e01b65623f72
parent 248 0bfcb6585290
child 269 81e72988dcb5
first version of benchmarks
- currently only one benchmark - matrix multiplication
benchmarks/matrix-multiplication/jsTestDriver.conf
benchmarks/matrix-multiplication/nbactions.xml
benchmarks/matrix-multiplication/pom.xml
benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Main.java
benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Matrix.java
benchmarks/matrix-multiplication/src/main/resources/org/apidesign/benchmark/matrixmul/multiplication-test.js
benchmarks/pom.xml
pom.xml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/benchmarks/matrix-multiplication/jsTestDriver.conf	Wed Dec 05 11:18:09 2012 +0100
     1.3 @@ -0,0 +1,6 @@
     1.4 +server: http://localhost:9876
     1.5 +
     1.6 +load:
     1.7 +  - target/classes/org/apidesign/benchmark/matrixmul/*.js
     1.8 +  - src/main/resources/org/apidesign/benchmark/matrixmul/*.js
     1.9 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/benchmarks/matrix-multiplication/nbactions.xml	Wed Dec 05 11:18:09 2012 +0100
     2.3 @@ -0,0 +1,29 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<!--
     2.6 +
     2.7 +    Back 2 Browser Bytecode Translator
     2.8 +    Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.9 +
    2.10 +    This program is free software: you can redistribute it and/or modify
    2.11 +    it under the terms of the GNU General Public License as published by
    2.12 +    the Free Software Foundation, version 2 of the License.
    2.13 +
    2.14 +    This program is distributed in the hope that it will be useful,
    2.15 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.16 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.17 +    GNU General Public License for more details.
    2.18 +
    2.19 +    You should have received a copy of the GNU General Public License
    2.20 +    along with this program. Look for COPYING file in the top folder.
    2.21 +    If not, see http://opensource.org/licenses/GPL-2.0.
    2.22 +
    2.23 +-->
    2.24 +<actions>
    2.25 +    <action>
    2.26 +        <actionName>run</actionName>
    2.27 +        <goals>
    2.28 +            <goal>process-classes</goal>
    2.29 +            <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
    2.30 +        </goals>
    2.31 +    </action>
    2.32 +</actions>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/benchmarks/matrix-multiplication/pom.xml	Wed Dec 05 11:18:09 2012 +0100
     3.3 @@ -0,0 +1,91 @@
     3.4 +<?xml version="1.0"?>
     3.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3.6 +  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     3.7 +  <modelVersion>4.0.0</modelVersion>
     3.8 +
     3.9 +  <groupId>org.apidesign.bck2brwsr</groupId>
    3.10 +  <artifactId>matrix.multiplication</artifactId>
    3.11 +  <version>0.3-SNAPSHOT</version>
    3.12 +  <packaging>jar</packaging>
    3.13 +
    3.14 +  <name>Matrix multiplication</name>
    3.15 +
    3.16 +  <properties>
    3.17 +    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    3.18 +  </properties>
    3.19 +  <build>
    3.20 +      <plugins>
    3.21 +          <plugin>
    3.22 +            <groupId>org.apache.maven.plugins</groupId>
    3.23 +            <artifactId>maven-compiler-plugin</artifactId>
    3.24 +            <version>2.3.2</version>
    3.25 +            <configuration>
    3.26 +               <source>1.7</source>
    3.27 +               <target>1.7</target>
    3.28 +            </configuration>
    3.29 +          </plugin>
    3.30 +          
    3.31 +          <plugin>
    3.32 +              <groupId>org.apidesign.bck2brwsr</groupId>
    3.33 +              <artifactId>mojo</artifactId>
    3.34 +              <version>0.3-SNAPSHOT</version>
    3.35 +              <executions>
    3.36 +                  <execution>
    3.37 +                      <goals>
    3.38 +                          <goal>j2js</goal>
    3.39 +                      </goals>
    3.40 +                  </execution>
    3.41 +              </executions>
    3.42 +          </plugin>
    3.43 +          
    3.44 +          <plugin>
    3.45 +            <groupId>com.googlecode.jstd-maven-plugin</groupId>
    3.46 +            <artifactId>jstd-maven-plugin</artifactId>
    3.47 +            <version>1.3.2.5</version>
    3.48 +            <configuration>
    3.49 +                <port>9876</port>
    3.50 +                <browser>/usr/bin/firefox</browser>
    3.51 +                <tests>all</tests>
    3.52 +                <config>jsTestDriver.conf</config>
    3.53 +                <reset>true</reset>
    3.54 +            </configuration>
    3.55 +            <executions>
    3.56 +                <execution>
    3.57 +                    <id>run-tests</id>
    3.58 +                    <goals>
    3.59 +                        <goal>test</goal>
    3.60 +                    </goals>
    3.61 +                </execution>
    3.62 +            </executions>
    3.63 +          </plugin>
    3.64 +      </plugins>
    3.65 +  </build>
    3.66 +
    3.67 +  <dependencies>
    3.68 +    <dependency>
    3.69 +      <groupId>org.apidesign.bck2brwsr</groupId>
    3.70 +      <artifactId>emul</artifactId>
    3.71 +      <version>0.3-SNAPSHOT</version>
    3.72 +    </dependency>
    3.73 +    <dependency>
    3.74 +        <groupId>com.googlecode.jstd-maven-plugin</groupId>
    3.75 +        <artifactId>jstd-maven-plugin</artifactId>
    3.76 +        <version>1.3.2.5</version>
    3.77 +        <scope>test</scope>
    3.78 +    </dependency>
    3.79 +  </dependencies>
    3.80 +  
    3.81 +  <repositories>
    3.82 +        <repository>
    3.83 +            <id>jstd-maven-plugin google code repo</id>
    3.84 +            <url>http://jstd-maven-plugin.googlecode.com/svn/maven2</url>
    3.85 +        </repository>
    3.86 +  </repositories>
    3.87 +  <pluginRepositories>
    3.88 +        <pluginRepository>
    3.89 +            <id>jstd-maven-plugin google code repo</id>
    3.90 +            <url>http://jstd-maven-plugin.googlecode.com/svn/maven2</url>
    3.91 +        </pluginRepository>
    3.92 +  </pluginRepositories>
    3.93 +  
    3.94 +</project>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Main.java	Wed Dec 05 11:18:09 2012 +0100
     4.3 @@ -0,0 +1,25 @@
     4.4 +package org.apidesign.benchmark.matrixmul;
     4.5 +
     4.6 +public class Main {
     4.7 +
     4.8 +    public static final int ITERATION_COUNT = 100000;
     4.9 +    
    4.10 +    public static void main(String[] args) {
    4.11 +        Matrix m1 = new Matrix(5);
    4.12 +        Matrix m2 = new Matrix(5);
    4.13 +        
    4.14 +        m1.generateData();
    4.15 +        m2.generateData();
    4.16 +        
    4.17 +        //m1.printOn(System.out);
    4.18 +        //System.out.println("x");
    4.19 +        //m2.printOn(System.out);
    4.20 +        
    4.21 +        for (int i = 0; i < ITERATION_COUNT; i++) {
    4.22 +            m1.multiply(m2);
    4.23 +        }
    4.24 +        
    4.25 +        //System.out.println("=");
    4.26 +        //m1.printOn(System.out);
    4.27 +    }
    4.28 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/benchmarks/matrix-multiplication/src/main/java/org/apidesign/benchmark/matrixmul/Matrix.java	Wed Dec 05 11:18:09 2012 +0100
     5.3 @@ -0,0 +1,64 @@
     5.4 +package org.apidesign.benchmark.matrixmul;
     5.5 +
     5.6 +//import java.io.PrintStream;
     5.7 +//import java.util.Random;
     5.8 +
     5.9 +public class Matrix {
    5.10 +
    5.11 +    private final int rank;
    5.12 +    private float data[][];
    5.13 +    
    5.14 +    public Matrix(int r) {
    5.15 +        rank = r;
    5.16 +        data = new float[r][r];
    5.17 +    }
    5.18 +    
    5.19 +    public void setElement(int i, int j, float value) {
    5.20 +        data[i][j] = value;
    5.21 +    }
    5.22 +    public float getElement(int i, int j) {
    5.23 +        return data[i][j];
    5.24 +    }
    5.25 +    
    5.26 +    public void generateData() {
    5.27 +        //final Random rand = new Random();
    5.28 +        //final int x = 10;
    5.29 +        for (int i = 0; i < rank; i++) {
    5.30 +            for (int j = 0; j < rank; j++) {
    5.31 +                data[i][j] = i + j;
    5.32 +            }
    5.33 +        }
    5.34 +    }
    5.35 +
    5.36 +    public Matrix multiply(Matrix m) {
    5.37 +        if (rank != m.rank) {
    5.38 +            throw new IllegalArgumentException("Rank doesn't match");
    5.39 +        }
    5.40 +        
    5.41 +        final float res[][] = new float[rank][rank];
    5.42 +        for (int i = 0; i < rank; i++) {
    5.43 +            for (int j = 0; j < rank; j++) {
    5.44 +                float ij = 0;
    5.45 +                for (int q = 0; q < rank; q++) {
    5.46 +                    ij += data[i][q] * m.data[q][j];
    5.47 +                }
    5.48 +                res[i][j] = ij;
    5.49 +            }
    5.50 +        }
    5.51 +        data = res;
    5.52 +        
    5.53 +        return this;
    5.54 +    }
    5.55 +    
    5.56 +    /*
    5.57 +    public void printOn(PrintStream s) {
    5.58 +        for (int i = 0; i < rank; i++) {
    5.59 +            for (int j = 0; j < rank; j++) {
    5.60 +                s.printf("%f ", data[i][j]);
    5.61 +            }
    5.62 +            s.println();
    5.63 +        }
    5.64 +    }
    5.65 +    */
    5.66 +    
    5.67 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/benchmarks/matrix-multiplication/src/main/resources/org/apidesign/benchmark/matrixmul/multiplication-test.js	Wed Dec 05 11:18:09 2012 +0100
     6.3 @@ -0,0 +1,6 @@
     6.4 +MatrixTest = TestCase("MatrixTest");
     6.5 +
     6.6 +MatrixTest.prototype.testMultiplication = function() {
     6.7 +  var x = new org_apidesign_benchmark_matrixmul_Main();
     6.8 +  x.main__V_3Ljava_lang_String_2(null);
     6.9 +};
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/benchmarks/pom.xml	Wed Dec 05 11:18:09 2012 +0100
     7.3 @@ -0,0 +1,17 @@
     7.4 +<?xml version="1.0" encoding="UTF-8"?>
     7.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     7.6 +  <modelVersion>4.0.0</modelVersion>
     7.7 +  <parent>
     7.8 +    <artifactId>bck2brwsr</artifactId>
     7.9 +    <groupId>org.apidesign</groupId>
    7.10 +    <version>0.3-SNAPSHOT</version>
    7.11 +  </parent>
    7.12 +  <groupId>org.apidesign.bck2brwsr</groupId>
    7.13 +  <artifactId>benchmarks</artifactId>
    7.14 +  <version>0.3-SNAPSHOT</version>
    7.15 +  <packaging>pom</packaging>
    7.16 +  <name>Performance benchmarks</name>
    7.17 +  <modules>
    7.18 +    <module>matrix-multiplication</module>
    7.19 +  </modules>
    7.20 +</project>
     8.1 --- a/pom.xml	Tue Dec 04 09:16:53 2012 +0100
     8.2 +++ b/pom.xml	Wed Dec 05 11:18:09 2012 +0100
     8.3 @@ -13,6 +13,7 @@
     8.4      <module>mojo</module>
     8.5      <module>javaquery</module>
     8.6      <module>javap</module>
     8.7 +    <module>benchmarks</module>
     8.8    </modules>
     8.9    <licenses>
    8.10        <license>
    8.11 @@ -70,6 +71,7 @@
    8.12                         <exclude>javap/**</exclude>
    8.13                         <exclude>*</exclude>
    8.14                         <exclude>.*/**</exclude>
    8.15 +                       <exclude>benchmarks/**</exclude>
    8.16                    </excludes>
    8.17                </configuration>
    8.18            </plugin>