25
25
import java .util .Random ;
26
26
27
27
import ch .ethz .globis .tinspin .TestStats ;
28
+ import org .junit .BeforeClass ;
28
29
import org .junit .Test ;
29
30
import org .tinspin .index .BoxMap ;
30
31
import org .tinspin .index .array .RectArray ;
31
32
import org .tinspin .index .test .util .JmxTools ;
32
33
import org .tinspin .index .test .util .TestBox ;
33
34
import org .tinspin .index .test .util .TestBoxCube ;
34
35
import org .tinspin .index .test .util .TestInstances .TST ;
36
+ import org .tinspin .index .test .util .TestRunner ;
35
37
36
38
import static org .tinspin .index .Index .*;
37
39
@@ -42,6 +44,11 @@ public class PhTreeTest {
42
44
private static final double param1 = 0.01 ;
43
45
private static final RectComp COMP = new RectComp ();
44
46
47
+ @ BeforeClass
48
+ public static void beforeClass () {
49
+ TestRunner .PRINT = false ;
50
+ }
51
+
45
52
@ Test
46
53
public void testR () {
47
54
Random R = new Random (0 );
@@ -76,7 +83,7 @@ private void load(BoxMap<Integer> tree, double[] data) {
76
83
private void repeatQuery (TestBox test , BoxMap <Integer > tree1 , BoxMap <Integer > tree2 , int repeat ) {
77
84
int dims = DIM ;
78
85
//log("N=" + N);
79
- log ("querying index ... repeat = " + repeat );
86
+ println ("querying index ... repeat = " + repeat );
80
87
double [][] lower = new double [repeat ][dims ];
81
88
double [][] upper = new double [repeat ][dims ];
82
89
test .generateWindowQueries (lower , upper );
@@ -85,7 +92,7 @@ private void repeatQuery(TestBox test, BoxMap<Integer> tree1, BoxMap<Integer> tr
85
92
int n = 0 ;
86
93
n = repeatQueries (tree1 , tree2 , lower , upper );
87
94
long t2 = System .currentTimeMillis ();
88
- log ("Query time: " + (t2 -t1 ) + " ms -> " + (t2 -t1 )/(double )repeat + " ms/q -> " +
95
+ println ("Query time: " + (t2 -t1 ) + " ms -> " + (t2 -t1 )/(double )repeat + " ms/q -> " +
89
96
(t2 -t1 )*1000 *1000 /(double )n + " ns/q/r (n=" + n + ")" );
90
97
}
91
98
@@ -107,24 +114,24 @@ private int repeatQueries(BoxMap<Integer> tree1, BoxMap<Integer> tree2, double[]
107
114
n2 ++;
108
115
}
109
116
if (n1 != n2 ) {
110
- log ("n1/n2=" + n1 + "/" + n2 );
111
- log ("q=" + Arrays .toString (lower [i ]) + "/" + Arrays .toString (upper [i ]));
117
+ println ("n1/n2=" + n1 + "/" + n2 );
118
+ println ("q=" + Arrays .toString (lower [i ]) + "/" + Arrays .toString (upper [i ]));
112
119
set1 .sort (COMP );
113
120
set2 .sort (COMP );
114
121
for (int j = 0 ; j < set1 .size (); j ++) {
115
122
BoxEntry <Integer > e1 = set1 .get (j );
116
123
BoxEntry <Integer > e2 = set2 .get (j );
117
124
if (!Arrays .equals (e1 .min (), e2 .min ()) ||
118
125
!Arrays .equals (e1 .max (), e2 .max ())) {
119
- log ("j=" + j + " mismatch: " + e1 + " -/- " + e2 );
126
+ println ("j=" + j + " mismatch: " + e1 + " -/- " + e2 );
120
127
}
121
128
}
122
129
}
123
130
assertEquals (n1 , n2 );
124
131
n += n1 ;
125
- if (i %10 == 0 ) System . out . print ('.' );
132
+ if (i %10 == 0 ) print ("." );
126
133
}
127
- System . out . println ();
134
+ println ("" );
128
135
//log("n=" + n/(double)lower.length);
129
136
return n ;
130
137
}
@@ -146,9 +153,17 @@ public int compare(BoxEntry<?> o1, BoxEntry<?> o2) {
146
153
return 0 ;
147
154
}
148
155
}
149
-
150
- private static void log (String string ) {
151
- System .out .println (string );
156
+
157
+ private static void println (String string ) {
158
+ if (TestRunner .PRINT ) {
159
+ System .out .println (string );
160
+ }
161
+ }
162
+
163
+ private static void print (String string ) {
164
+ if (TestRunner .PRINT ) {
165
+ System .out .print (string );
166
+ }
152
167
}
153
168
154
169
}
0 commit comments