Author: nextgens
Date: 2009-04-02 22:30:59 +0000 (Thu, 02 Apr 2009)
New Revision: 26391
Modified:
trunk/freenet/test/freenet/client/CodeTest.java
Log:
Add a benchmark to the junit test; launch it with -Dbenchmark=true
At the moment it produces weird results:
[junit] Getting ready for benchmarking
[junit] Native8Code[k=192,n=256]
[junit] PureCode[k=192,n=256]
[junit] Native code took 239ms whereas java's code took 76ms.
Modified: trunk/freenet/test/freenet/client/CodeTest.java
===================================================================
--- trunk/freenet/test/freenet/client/CodeTest.java 2009-04-02 22:05:09 UTC
(rev 26390)
+++ trunk/freenet/test/freenet/client/CodeTest.java 2009-04-02 22:30:59 UTC
(rev 26391)
@@ -12,6 +12,7 @@
public class CodeTest extends TestCase {
+ private static final boolean BENCHMARK =
Boolean.getBoolean("benchmark");
public static FECMath fecMath = new FECMath(8);
public static final int KK = 192;
@@ -41,6 +42,31 @@
Assert.assertEquals(src[i], repair[i]);
}
+ public void testBenchmark() {
+ if(!BENCHMARK) return;
+
+ int lim = fecMath.gfSize + 1;
+ FECCode maybeNative =
FECCodeFactory.getDefault().createFECCode(KK, lim);
+ FECCode pureCode = new PureCode(KK, lim);
+ int[] index = new int[KK];
+
+ for (int i = 0; i < KK; i++)
+ index[i] = lim - i - 1;
+
+ System.out.println("Getting ready for benchmarking");
+ long t1 = System.currentTimeMillis();
+ encodeDecode(maybeNative, maybeNative, index);
+ long t2 = System.currentTimeMillis();
+ encodeDecode(pureCode, pureCode, index);
+ long t3 = System.currentTimeMillis();
+
+ System.out.println(maybeNative);
+ System.out.println(pureCode);
+ long dNative = t2 - t1;
+ long dPure = t3 - t2;
+ System.out.println("Native code took "+dNative+"ms whereas
java's code took "+dPure+"ms.");
+ }
+
public void testSimpleRev() {
int lim = fecMath.gfSize + 1;
FECCode code = FECCodeFactory.getDefault().createFECCode(KK,
lim);
@@ -49,6 +75,7 @@
for (int i = 0; i < KK; i++)
index[i] = lim - i - 1;
+
encodeDecode(code, code2, index);
encodeDecode(code2, code, index);
}
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs