我想计算方法(encryptTree)
的运行时间,此方法调用其他方法(encrypt)
,如下所示:
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;
}
}
我想使用new Date().getTime()
来计算encryptTree
的运行时间,以确保它包含其中的所有方法。当我尝试使用它时:
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;
}
但我没有得到正确的结果。