text: BloomFilter = require("./bloomfilter").BloomFilter;
  
  function lpad(str, n) {
    return Array(Math.max(n - String(str).length + 1, 0)).join(' ') + str;
  }
  
  
  function testDataSet(dataset, align) {
    align = align || 7;
  
    var m = -dataset.length * Math.log(.01) / (Math.LN2 * Math.LN2);
  
    var bf = new BloomFilter(m, Math.ceil(m / dataset.length * Math.LN2));
  
    console.log('Start %d iterations', dataset.length);
    for (var i=0; i<dataset.length-1; i++) {
      var key = dataset[i];
  
      bf.add(key);
      var stats = {
        not: 0,
        maybe: 0
      }
      for (var j=0; j<=i; j++) {
        if (!bf.test(dataset[j])) {
          console.log('Hmm... problem with key: %s', dataset[j]);
          process.exit(0);
        }
      }
      for (var j=i+1; j<dataset.length; j++) {
        if (bf.test(dataset[j])) {
          stats.maybe++;
        } else {
          stats.not++;
        }
      }
  
      var notpct = (stats.not * 100/ (dataset.length - i - 1)).toFixed(2)+'%';
  
      if (i%500 == 0) {
        console.log('Iter[%s/%s]: %s | %s | %s | key:[%s]',
                    lpad(i, align),
                    lpad(dataset.length, align),
                    lpad(notpct, align),
                    lpad(stats.not, align),
                    lpad(stats.maybe, align), key);
      }
    }
  }
  
  var dataset = [];
  for (var i = 0; i < 1e4; ++i) dataset.push(Math.random() + "");
  
  testDataSet(dataset);
  