Author: nextgens
Date: 2009-04-14 22:16:22 +0000 (Tue, 14 Apr 2009)
New Revision: 26811

Modified:
   trunk/freenet/test/freenet/client/CodeTest.java
Log:
fix the FEC benchmarking code:
    [junit] Getting ready for benchmarking encode()
    [junit] Getting ready for benchmarking decode()
    [junit] Native8Code[k=192,n=256]
    [junit] PureCode[k=192,n=256]
    [junit] Native code took 92.0ms whereas java's code took 321.0ms to encode()
    [junit] Native code took 94.0ms whereas java's code took 334.0ms to decode()


Modified: trunk/freenet/test/freenet/client/CodeTest.java
===================================================================
--- trunk/freenet/test/freenet/client/CodeTest.java     2009-04-14 22:06:10 UTC 
(rev 26810)
+++ trunk/freenet/test/freenet/client/CodeTest.java     2009-04-14 22:16:22 UTC 
(rev 26811)
@@ -53,18 +53,47 @@
                for (int i = 0; i < KK; i++)
                        index[i] = lim - i - 1;
 
-               System.out.println("Getting ready for benchmarking");
+               byte[] src = new byte[KK * PACKET_SIZE];
+               Util.rand.nextBytes(src);
+               Buffer[] srcBufs = new Buffer[KK];
+               for (int i = 0; i < srcBufs.length; i++)
+                       srcBufs[i] = new Buffer(src, i * PACKET_SIZE, 
PACKET_SIZE);
+
+               byte[] repair = new byte[KK * PACKET_SIZE];
+               Buffer[] repairBufs = new Buffer[KK];
+               for (int i = 0; i < repairBufs.length; i++) {
+                       repairBufs[i] = new Buffer(repair, i * PACKET_SIZE, 
PACKET_SIZE);
+               }
+
+               int[] indexBackup = new int[index.length];
+               System.arraycopy(index,0,indexBackup,0,index.length);
+
+               System.out.println("Getting ready for benchmarking encode()");
                long t1 = System.currentTimeMillis();
-               encodeDecode(maybeNative, maybeNative, index);
+               maybeNative.encode(srcBufs, repairBufs, index);
                long t2 = System.currentTimeMillis();
-               encodeDecode(pureCode, pureCode, index);
+               pureCode.encode(srcBufs, repairBufs, indexBackup);
                long t3 = System.currentTimeMillis();
 
+               float dNativeEncode = t2 - t1;
+               float dPureEncode = t3 - t2;
+
+               Buffer[] repairBufs2 = repairBufs.clone();
+               System.arraycopy(repairBufs, 0, repairBufs2, 0, 
repairBufs.length);
+               System.out.println("Getting ready for benchmarking decode()");
+               t1 = System.currentTimeMillis();
+               maybeNative.decode(repairBufs, index);
+               t2 = System.currentTimeMillis();
+               pureCode.decode(repairBufs2, indexBackup);
+               t3 = System.currentTimeMillis();
+
+               float dNativeDecode = t2 - t1;
+               float dPureDecode = t3 - t2;
+
                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.");
+               System.out.println("Native code took "+dNativeEncode+"ms 
whereas java's code took "+dPureEncode+"ms to encode()");
+               System.out.println("Native code took "+dNativeDecode+"ms 
whereas java's code took "+dPureDecode+"ms to decode()");
        }
 
        public void testSimpleRev() {

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to