[Bigintbench-discuss] SF.net SVN: bigintbench: [1]
Status: Planning
Brought to you by:
captain5050
From: <cap...@us...> - 2006-08-29 12:18:58
|
Revision: 1 Author: captain5050 Date: 2006-08-29 05:18:38 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/bigintbench/?rev=1&view=rev Log Message: ----------- Initial benchmarks Added Paths: ----------- .classpath .project bigintbench/ bigintbench/sf/ bigintbench/sf/net/ bigintbench/sf/net/Benchmark.class bigintbench/sf/net/Benchmark.java bigintbench/sf/net/Divide.class bigintbench/sf/net/Divide.java bigintbench/sf/net/Multiply.class bigintbench/sf/net/Multiply.java bigintbench/sf/net/Runbench.class bigintbench/sf/net/Runbench.java Added: .classpath =================================================================== --- .classpath (rev 0) +++ .classpath 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry path="" kind="src"/> + <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/> + <classpathentry path="" kind="output"/> +</classpath> Added: .project =================================================================== --- .project (rev 0) +++ .project 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>bigintbench.sf.net</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: bigintbench/sf/net/Benchmark.class =================================================================== (Binary files differ) Property changes on: bigintbench/sf/net/Benchmark.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: bigintbench/sf/net/Benchmark.java =================================================================== --- bigintbench/sf/net/Benchmark.java (rev 0) +++ bigintbench/sf/net/Benchmark.java 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,46 @@ +/** + * + */ +package bigintbench.sf.net; +import java.util.Random; + +/** + * @author irogers + * + */ +public abstract class Benchmark implements Runnable { + /** + * Random number generator for all benchmarks + */ + protected static final Random random = new Random(); + /** + * Prefered duration of a benchmark that measures throughput + */ + protected static final int preferedDurationInSeconds = 3; + /** + * Method implemented by each benchmark to run it + */ + protected abstract void runBenchmark(); + /** + * Report the time taken to run the benchmark + * @param result + */ + protected static void reportResult(String result){ + System.out.println("RESULT: " + result); + } + /** + * Verbose running information + * @param verboseInformation + */ + protected static void verbose(String verboseInformation){ + if (false) { + System.out.println(verboseInformation); + } + } + /** + * Method to run each benchmark + */ + public void run(){ + runBenchmark(); + } +} Added: bigintbench/sf/net/Divide.class =================================================================== (Binary files differ) Property changes on: bigintbench/sf/net/Divide.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: bigintbench/sf/net/Divide.java =================================================================== --- bigintbench/sf/net/Divide.java (rev 0) +++ bigintbench/sf/net/Divide.java 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,61 @@ +/** + * + */ +package bigintbench.sf.net; +import java.math.BigInteger; + +/** + * @author irogers + * + */ +public class Divide extends Benchmark { + /** + * Arguments to benchmark + */ + private final BigInteger x[]; + private final BigInteger y[]; + private final long numIterations[]; + + /** + * + * @param args + */ + Divide(int args[][]) { + int numArgs = args.length; + x = new BigInteger[numArgs]; + y = new BigInteger[numArgs]; + numIterations = new long[numArgs]; + for(int i=0; i < numArgs; i++) { + verbose("Divide initializing " + i); + int m = args[i][0]; + int n = args[i][1]; + x[i] = new BigInteger(m, random); + y[i] = new BigInteger(n, random); + long startTime = System.currentTimeMillis(); + x[i].divide(y[i]); + long endTime = System.currentTimeMillis(); + numIterations[i] = (long)((preferedDurationInSeconds * 1000.0d) / ((double)(endTime - startTime + 1))); + } + verbose("Divide initialized"); + } + + /** + * Run the divide benchmark for each argument + */ + protected void runBenchmark() { + int numArgs = numIterations.length; + for(int i=0; i < numArgs ; i++) { + BigInteger _x = x[i]; + BigInteger _y = y[i]; + long iterations = numIterations[i]; + verbose("Starting benchmark Divide " + i + " iterations=" + iterations); + long startTime = System.currentTimeMillis(); + for(long j=0; j < iterations; j++) { + @SuppressWarnings("unused") BigInteger z = _x.divide(_y); + } + long endTime = System.currentTimeMillis(); + reportResult("Divide: run " + i + " took " + (endTime - startTime) + "ms" + " iterations/second=" + + (((double)iterations) / ((endTime - startTime) / 1000.0d))); + } + } +} Added: bigintbench/sf/net/Multiply.class =================================================================== (Binary files differ) Property changes on: bigintbench/sf/net/Multiply.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: bigintbench/sf/net/Multiply.java =================================================================== --- bigintbench/sf/net/Multiply.java (rev 0) +++ bigintbench/sf/net/Multiply.java 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,61 @@ +/** + * + */ +package bigintbench.sf.net; +import java.math.BigInteger; + +/** + * @author irogers + * + */ +public class Multiply extends Benchmark { + /** + * Arguments to benchmark + */ + private final BigInteger x[]; + private final BigInteger y[]; + private final long numIterations[]; + + /** + * + * @param args + */ + Multiply(int args[][]) { + int numArgs = args.length; + x = new BigInteger[numArgs]; + y = new BigInteger[numArgs]; + numIterations = new long[numArgs]; + for(int i=0; i < numArgs; i++) { + verbose("Multiply initializing " + i); + int m = args[i][0]; + int n = args[i][1]; + x[i] = new BigInteger(m, random); + y[i] = new BigInteger(n, random); + long startTime = System.currentTimeMillis(); + x[i].multiply(y[i]); + long endTime = System.currentTimeMillis(); + numIterations[i] = (long)((preferedDurationInSeconds * 1000.0d) / ((double)(endTime - startTime + 1))); + } + verbose("Multiply initialized"); + } + + /** + * Run the multiply benchmark for each argument + */ + protected void runBenchmark() { + int numArgs = numIterations.length; + for(int i=0; i < numArgs ; i++) { + BigInteger _x = x[i]; + BigInteger _y = y[i]; + long iterations = numIterations[i]; + verbose("Starting benchmark multiply " + i + " iterations=" + iterations); + long startTime = System.currentTimeMillis(); + for(long j=0; j < iterations; j++) { + @SuppressWarnings("unused") BigInteger z = _x.multiply(_y); + } + long endTime = System.currentTimeMillis(); + reportResult("Multiply: run " + i + " took " + (endTime - startTime) + "ms" + " iterations/second=" + + (((double)iterations) / ((endTime - startTime) / 1000.0d))); + } + } +} Added: bigintbench/sf/net/Runbench.class =================================================================== (Binary files differ) Property changes on: bigintbench/sf/net/Runbench.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: bigintbench/sf/net/Runbench.java =================================================================== --- bigintbench/sf/net/Runbench.java (rev 0) +++ bigintbench/sf/net/Runbench.java 2006-08-29 12:18:38 UTC (rev 1) @@ -0,0 +1,57 @@ +/** + * + */ +package bigintbench.sf.net; + +/** + * @author irogers + * + */ +public class Runbench { + /** + * Arguments for the divide benchmark + */ + private static int divideArgs[][]={ + {8192,32}, // 0 + {8192,64}, // 1 + {8192,128}, // 2 + {8192,4096}, // 3 + {8192,8064}, // 4 + {131072,8192}, // 5 + {131072,65536}}; // 6 + //,{8388608,4194304}}; // 7 + /** + * Arguments for the multiply benchmark + */ + private static int multiplyArgs[][]={ + {128,128}, // 0 + {512,512}, // 1 + {8192,8192}, // 2 + {131072,131072}}; // 3 + //{2097152,2097152}}; // 4 + /** + * Arguments for the RSA benchmark + */ + private static int rsaArgs[] = {512, 1024, 2048}; + + /** + * Array of benchmarks to be run + */ + private static final Benchmark benchmarks[] = { + new Divide(divideArgs), + new Multiply(multiplyArgs)}; + + /** + * Run the benchmarks from the command line + * @param args + */ + public static void main(String[] args) { + System.out.println("Running BigInteger benchmarks"); + for(int i=0; i < 3; i++) { + for(int j=0; j < benchmarks.length; j++) { + benchmarks[j].run(); + } + } + System.out.println("Finished BigInteger benchmarks"); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |