Changes in / [2cd9b34:8f4f7b7b]


Ignore:
Files:
5 added
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • build.properties

    r2cd9b34 r8f4f7b7b  
    125125#with.clover=/PATH/TO/clover.jar
    126126
     127
     128### Benchmarks ##
     129# Location of the JMH libraries
     130# Defaults to the ant library path if not set
     131# If set, this must point to a directory containing the files
     132#       jmh-core.jar, jmh-generator-annprocess.jar, jopt-simple.jar, commons-math3.jar
     133# Tested using JMH 1.19 which requires jopt-simple 4.6 and commons-math3 3.2
     134#jmh.home=
     135
     136
    127137### Bundle router infos ###
    128138# Set to bundle router infos from your local I2P install in the package
  • build.xml

    r2cd9b34 r8f4f7b7b  
    5959        <echo message="  poupdate: update the .po files for translators" />
    6060        <echo message="  pkg-portable-win32:  build a minimum portable version for win32" />
     61        <echo message="  bench: build the benchmarks" />
    6162   </target>
    6263    <target name="debianhowto">
     
    18441845
    18451846    <target name="testscripts-all" depends="testscripts,testscripts-net" />
     1847
     1848    <target name="bench" depends="jbigi" >
     1849        <ant dir="core/java/" target="bench.jar" />
     1850    </target>
    18461851
    18471852    <!-- <target name="syndie" >
  • core/java/build.xml

    r2cd9b34 r8f4f7b7b  
    383383    <!-- end unit tests -->
    384384
     385    <!-- benchmarks -->
     386    <target name="jmhLibCheck">
     387        <!-- override to Ant home if not set -->
     388        <property name="jmh.home" value="${ant.home}/lib" />
     389        <fail message="Please set jmh.home to a directory containing the necessary JMH libraries. See build.properties for details.">
     390            <condition>
     391                <not>
     392                    <and>
     393                        <available file="${jmh.home}/jmh-core.jar" />
     394                        <available file="${jmh.home}/jmh-generator-annprocess.jar" />
     395                        <available file="${jmh.home}/jopt-simple.jar" />
     396                        <available file="${jmh.home}/commons-math3.jar" />
     397                    </and>
     398                </not>
     399            </condition>
     400        </fail>
     401    </target>
     402
     403    <target name="bench.compile" depends="compile, jmhLibCheck">
     404        <mkdir dir="./build" />
     405        <mkdir dir="./build/obj_bench" />
     406        <javac srcdir="./bench" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
     407               debuglevel="lines,vars,source"
     408               includeAntRuntime="false"
     409               destdir="./build/obj_bench" >
     410            <classpath>
     411                <pathelement location="${jmh.home}/jmh-core.jar" />
     412                <pathelement location="${jmh.home}/jmh-generator-annprocess.jar" />
     413                <pathelement location="./build/obj" />
     414            </classpath>
     415            <compilerarg line="${javac.compilerargs}" />
     416        </javac>
     417    </target>
     418
     419    <target name="bench.jar" depends="bench.compile, bench.jarUpToDate, listChangedFiles" unless="bench.jar.uptodate" >
     420        <!-- set if unset -->
     421        <property name="workspace.changes.tr" value="" />
     422        <jar destfile="./build/i2p-benchmarks.jar" basedir="./build/obj_bench" >
     423            <manifest>
     424                <attribute name="Built-By" value="${build.built-by}" />
     425                <attribute name="Build-Date" value="${build.timestamp}" />
     426                <attribute name="Base-Revision" value="${workspace.version}" />
     427                <attribute name="Main-Class" value="org.openjdk.jmh.Main" />
     428                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
     429                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
     430                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
     431            </manifest>
     432            <zipfileset src="${jmh.home}/jmh-core.jar" excludes="**/META-INF/services/**" />
     433            <zipfileset src="${jmh.home}/jopt-simple.jar" />
     434            <zipfileset src="${jmh.home}/commons-math3.jar" />
     435            <fileset dir="./build/obj" includes="**/*.class" />
     436        </jar>
     437    </target>
     438
     439    <target name="bench.jarUpToDate">
     440        <uptodate property="bench.jar.uptodate" targetfile="build/i2p-benchmarks.jar" >
     441            <srcfiles dir= "build/obj" includes="**/*.class" />
     442            <srcfiles dir= "build/obj_bench" includes="**/*.class" />
     443        </uptodate>
     444    </target>
     445
    385446    <target name="clean">
    386447        <delete dir="./build" />
  • core/java/src/net/i2p/crypto/ElGamalEngine.java

    r2cd9b34 r8f4f7b7b  
    251251        return null;
    252252    }
    253 
    254 /****
    255     public static void main(String args[]) {
    256         long eTime = 0;
    257         long dTime = 0;
    258         long gTime = 0;
    259         int numRuns = 100;
    260         if (args.length > 0) try {
    261             numRuns = Integer.parseInt(args[0]);
    262         } catch (NumberFormatException nfe) { // nop
    263         }
    264 
    265         try {
    266             Thread.sleep(30 * 1000);
    267         } catch (InterruptedException ie) { // nop
    268         }
    269 
    270         RandomSource.getInstance().nextBoolean();
    271         I2PAppContext context = new I2PAppContext();
    272 
    273         System.out.println("Running " + numRuns + " times");
    274 
    275         for (int i = 0; i < numRuns; i++) {
    276             long startG = Clock.getInstance().now();
    277             Object pair[] = KeyGenerator.getInstance().generatePKIKeypair();
    278             long endG = Clock.getInstance().now();
    279 
    280             PublicKey pubkey = (PublicKey) pair[0];
    281             PrivateKey privkey = (PrivateKey) pair[1];
    282             byte buf[] = new byte[128];
    283             RandomSource.getInstance().nextBytes(buf);
    284             long startE = Clock.getInstance().now();
    285             byte encr[] = context.elGamalEngine().encrypt(buf, pubkey);
    286             long endE = Clock.getInstance().now();
    287             byte decr[] = context.elGamalEngine().decrypt(encr, privkey);
    288             long endD = Clock.getInstance().now();
    289             eTime += endE - startE;
    290             dTime += endD - endE;
    291             gTime += endG - startG;
    292 
    293             if (!DataHelper.eq(decr, buf)) {
    294                 System.out.println("PublicKey     : " + DataHelper.toString(pubkey.getData(), pubkey.getData().length));
    295                 System.out.println("PrivateKey    : " + DataHelper.toString(privkey.getData(), privkey.getData().length));
    296                 System.out.println("orig          : " + DataHelper.toString(buf, buf.length));
    297                 System.out.println("d(e(orig)     : " + DataHelper.toString(decr, decr.length));
    298                 System.out.println("orig.len      : " + buf.length);
    299                 System.out.println("d(e(orig).len : " + decr.length);
    300                 System.out.println("Not equal!");
    301                 System.exit(0);
    302             } else {
    303                 System.out.println("*Run " + i + " is successful, with encr.length = " + encr.length + " [E: "
    304                                    + (endE - startE) + " D: " + (endD - endE) + " G: " + (endG - startG) + "]\n");
    305             }
    306         }
    307         System.out.println("\n\nAll " + numRuns + " tests successful, average encryption time: " + (eTime / numRuns)
    308                            + " average decryption time: " + (dTime / numRuns) + " average key generation time: "
    309                            + (gTime / numRuns));
    310     }
    311 ****/
    312253}
  • core/java/src/net/i2p/crypto/SHA256Generator.java

    r2cd9b34 r8f4f7b7b  
    9393        }
    9494    }
    95 
    96     //private static final int RUNS = 100000;
    97 
    98     /**
    99      *  Test the GNU and the JVM's implementations for speed
    100      *
    101      *  Results: 2011-05 eeepc Atom
    102      *  <pre>
    103      *  JVM     strlen  GNU ms  JVM  ms
    104      *  Oracle  387       3861   3565
    105      *  Oracle   40        825    635
    106      *  Harmony 387       8082   5158
    107      *  Harmony  40       4137   1753
    108      *  JamVM   387      36301  34100
    109      *  JamVM    40       7022   6016
    110      *  gij     387     125833   4342
    111      *  gij      40      22417    988
    112      *  </pre>
    113      */
    114 /****
    115     public static void main(String args[]) {
    116         if (args.length <= 0) {
    117             System.err.println("Usage: SHA256Generator string");
    118             return;
    119         }
    120 
    121         byte[] data = args[0].getBytes();
    122         Sha256Standalone gnu = new Sha256Standalone();
    123         long start = System.currentTimeMillis();
    124         for (int i = 0; i < RUNS; i++) {
    125             gnu.update(data, 0, data.length);
    126             byte[] sha = gnu.digest();
    127             if (i == 0)
    128                 System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");
    129             gnu.reset();
    130         }
    131         long time = System.currentTimeMillis() - start;
    132         System.out.println("Time for " + RUNS + " SHA-256 computations:");
    133         System.out.println("GNU time (ms): " + time);
    134 
    135         start = System.currentTimeMillis();
    136         MessageDigest md;
    137         try {
    138             md = MessageDigest.getInstance("SHA-256");
    139         } catch (NoSuchAlgorithmException e) {
    140             System.err.println("Fatal: " + e);
    141             return;
    142         }
    143         for (int i = 0; i < RUNS; i++) {
    144             md.reset();
    145             byte[] sha = md.digest(data);
    146             if (i == 0)
    147                 System.out.println("SHA256 [" + args[0] + "] = [" + Base64.encode(sha) + "]");
    148         }
    149         time = System.currentTimeMillis() - start;
    150 
    151         System.out.println("JVM time (ms): " + time);
    152     }
    153 ****/
    15495}
  • core/perl/i2pbench.sh

    r2cd9b34 r8f4f7b7b  
    2020print "\nBenchmark Suite #1: i2p/core/java/test/net/i2p/crypto/*\n\n";
    2121
    22 @testclasses = ( "AES256Bench", "DSABench", "ElGamalBench", "SHA256Bench" );
     22@testclasses = ( "DSABench" );
    2323
    2424foreach $testclass (@testclasses) {
Note: See TracChangeset for help on using the changeset viewer.