Author: toad
Date: 2008-09-26 18:42:28 +0000 (Fri, 26 Sep 2008)
New Revision: 22850

Removed:
   branches/db4o/freenet/src/freenet/support/BloomFilterTest.java
Log:
Remove duplicate copy


Deleted: branches/db4o/freenet/src/freenet/support/BloomFilterTest.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/BloomFilterTest.java      
2008-09-26 18:39:46 UTC (rev 22849)
+++ branches/db4o/freenet/src/freenet/support/BloomFilterTest.java      
2008-09-26 18:42:28 UTC (rev 22850)
@@ -1,67 +0,0 @@
-package freenet.support;
-
-import java.util.Random;
-
-import org.spaceroots.mantissa.random.MersenneTwister;
-
-public class BloomFilterTest {
-
-       /**
-        * @param args
-        */
-       public static void main(String[] args) {
-               Random mt = new MersenneTwister();
-               /**
-                * Create a Bloom filter. Fill it with random data.
-                * Request random data from it, show how many true negatives
-                * and how many false positives.
-                */
-               if(args.length != 2) {
-                       System.err.println("java 
"+BloomFilterTest.class.getName()+" <key count> <keys to bloom elements 
ratio>");
-                       System.exit(1);
-               }
-               int keyCount = Integer.parseInt(args[0]);
-               int ratio = Integer.parseInt(args[1]);
-               int size = keyCount * ratio;
-               if(size % 8 != 0)
-                       size += (8 - size % 8);
-               int k = (int) (0.7 * ratio);
-               System.out.println("Size in elements: "+size);
-               System.out.println("Key count: "+keyCount);
-               System.out.println("False positives should be: 
"+Math.pow(0.6185, ratio));
-               BloomFilter filter = new CountingBloomFilter(size, k);
-               int detected = 0;
-               for(int i=0;i<keyCount;i++) {
-                       byte[] buf = new byte[32];
-                       mt.nextBytes(buf);
-                       filter.addKey(buf);
-                       if(filter.checkFilter(buf)) {
-                               detected++;
-                       }
-               }
-               if(detected < keyCount) {
-                       System.err.println("FAILED TO DETECT KEY:");
-                       System.err.println("Key count: "+keyCount);
-                       System.err.println("Detected keys: "+detected);
-                       System.exit(2);
-               } else
-                       System.out.println("Detected keys: "+detected);
-               int countNegatives = 0;
-               int countFalsePositives = 0;
-               int count = 0;
-               while(true) {
-                       byte[] buf = new byte[32];
-                       mt.nextBytes(buf);
-                       if(filter.checkFilter(buf)) {
-                               countFalsePositives++;
-                       } else {
-                               countNegatives++;
-                       }
-                       count++;
-                       if(count % (16 * 1024) == 0) {
-                               System.out.println("Negatives: 
"+countNegatives+" false positives: 
"+countFalsePositives+((countFalsePositives==0) ? " (no false positives)" : " 
ratio "+(countNegatives / countFalsePositives)));
-                       }
-               }
-       }
-
-}


Reply via email to