0

i want to calculate running time of method (encryptTree)and this method call inside it other method(encrypt) as the follwoing:

public  BloomFilterIndex encryptTree(BloomFilterIndex tree) {
    for(int m=0;m<tree.root.children.size();m++){
        BloomFilterIndex.BFINode<Integer>n = (BloomFilterIndex.BFINode<Integer>) tree.root.children.get(m);
        encrypt(n);
    }
    return tree;
}

public void encrypt(BloomFilterIndex.BFINode<Integer> root) {
    List<double[]> ress = new ArrayList<>();
    if(!root.isLeaf()){
        c = new double[root.value.size()];
        for (int i = 0; i < root.value.size(); i++) {
            c[i] =root.value.getBitSet().getWord(i);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
        } 
        ress.add(c);
        root.value = null;
        root.value2 = ress;

        for(BloomFilterIndex.BFINode<Integer> g:root.children)
            encrypt(g);

     } else {
        double[] y = new double[400];
        double[] z = new double[400];
        Random r = new Random();
        Integer g1 = r.nextInt();
        double m5 = (double) ((double) Math.round(g1 * 10) / 10.0);
        java.util.Vector<Double> m6 = new java.util.Vector<Double>(400);
        java.util.Vector<Double> n1 = new java.util.Vector<Double>(400);

        for (int i = 0; i < s.size(); i++) {
            if (s.get(i) == 1) {
                m6.add((double) root.value.getBitSet().getWord(i));
                n1.add((double) root.value.getBitSet().getWord(i));
            } else {
                m6.add( 0.5 * (root.value.getBitSet().getWord(i))+m5);
                n1.add( 0.5 * (root.value.getBitSet().getWord(i))+m5 );
            }
        }

        for (int i = 0; i < 400;i++) {
            for (int j = 0; j < 400; j++) {
                y[i] += a2[i][j] * m6.get(j);
                z[i] += b2[i][j] * n1.get(j);
            }
        }
        ress.add(y);
        ress.add(z);
        root.value = null;
        root.value2 = ress;
    }
}

i want to use new Date().getTime() to calculate the running time of encryptTree that guarantee it contain all method inside it. when i try to use it as:

public  BloomFilterIndex encryptTree(BloomFilterIndex tree) {
    startTime9=new Date().getTime();
    for(int m=0;m<tree.root.children.size();m++){
        BloomFilterIndex.BFINode<Integer> n = (BloomFilterIndex.BFINode<Integer>) tree.root.children.get(m);
        encrypt(n);
    }
    end=new Date().getTime()-startTime9;
    end/=1000.0;
    System.out.println("encrypt node in :"+end);

    return tree;
}

but i not get the correct result.

Taylor
  • 3,942
  • 2
  • 20
  • 33

0 Answers0