23
23
import com .graphhopper .coll .GHBitSet ;
24
24
import com .graphhopper .coll .GHBitSetImpl ;
25
25
import com .graphhopper .routing .util .*;
26
+ import com .graphhopper .storage .*;
26
27
import com .graphhopper .storage .index .LocationIndex ;
27
- import com .graphhopper .storage .Graph ;
28
- import com .graphhopper .storage .GraphStorage ;
29
- import com .graphhopper .storage .NodeAccess ;
30
- import com .graphhopper .storage .RAMDirectory ;
31
28
import com .graphhopper .util .*;
32
29
import com .graphhopper .util .shapes .BBox ;
33
30
@@ -116,12 +113,13 @@ void start( CmdArgs args )
116
113
throw new IllegalStateException ("Graph has to be unprepared but wasn't!" );
117
114
118
115
String vehicleStr = args .get ("graph.flagEncoders" , "" );
116
+ FlagEncoder encoder = hopper .getEncodingManager ().getEncoder (vehicleStr );
119
117
StopWatch sw = new StopWatch ().start ();
120
118
try
121
119
{
122
120
maxNode = g .getNodes ();
123
121
GHBitSet allowedEdges = printGraphDetails (g , vehicleStr );
124
- printMiscUnitPerfTests (hopper , vehicleStr , count * 100 , allowedEdges );
122
+ printMiscUnitPerfTests (false , g , encoder , count * 100 , allowedEdges );
125
123
printLocationIndexQuery (g , hopper .getLocationIndex (), count );
126
124
127
125
// Route via dijkstrabi. Normal routing takes a lot of time => smaller query number than CH
@@ -134,6 +132,10 @@ void start( CmdArgs args )
134
132
// route via CH. do preparation before
135
133
hopper .setCHEnable (true );
136
134
hopper .doPostProcessing ();
135
+
136
+ LevelGraph lg = (LevelGraph ) g ;
137
+ fillAllowedEdges (lg .getAllEdges (), allowedEdges );
138
+ printMiscUnitPerfTests (true , lg , encoder , count * 100 , allowedEdges );
137
139
printTimeOfRouteQuery (hopper , count , "routingCH" , vehicleStr , true );
138
140
printTimeOfRouteQuery (hopper , count , "routingCH_no_instr" , vehicleStr , false );
139
141
logger .info ("store into " + propLocation );
@@ -161,6 +163,15 @@ void start( CmdArgs args )
161
163
}
162
164
}
163
165
166
+ void fillAllowedEdges ( AllEdgesIterator iter , GHBitSet bs )
167
+ {
168
+ bs .clear ();
169
+ while (iter .next ())
170
+ {
171
+ bs .add (iter .getEdge ());
172
+ }
173
+ }
174
+
164
175
private GHBitSet printGraphDetails ( GraphStorage g , String vehicleStr )
165
176
{
166
177
// graph size (edge, node and storage size)
@@ -172,10 +183,7 @@ private GHBitSet printGraphDetails( GraphStorage g, String vehicleStr )
172
183
AllEdgesIterator iter = g .getAllEdges ();
173
184
final int maxEdgesId = g .getAllEdges ().getCount ();
174
185
final GHBitSet allowedEdges = new GHBitSetImpl (maxEdgesId );
175
- while (iter .next ())
176
- {
177
- allowedEdges .add (iter .getEdge ());
178
- }
186
+ fillAllowedEdges (iter , allowedEdges );
179
187
put ("graph.valid_edges" , allowedEdges .getCardinality ());
180
188
return allowedEdges ;
181
189
}
@@ -205,13 +213,47 @@ public int doCalc( boolean warmup, int run )
205
213
print ("location2id" , miniPerf );
206
214
}
207
215
208
- private void printMiscUnitPerfTests ( final GraphHopper hopper , String vehicle , int count ,
209
- final GHBitSet allowedEdges )
216
+ private void printMiscUnitPerfTests ( boolean isCH , final Graph graph , final FlagEncoder encoder ,
217
+ int count , final GHBitSet allowedEdges )
210
218
{
211
219
final Random rand = new Random (seed );
212
- final GraphStorage graph = hopper .getGraph ();
220
+ String description = "" ;
221
+ if (isCH )
222
+ {
223
+ description = "CH" ;
224
+ LevelGraph lg = (LevelGraph ) graph ;
225
+ final EdgeSkipExplorer chExplorer = lg .createEdgeExplorer (
226
+ new LevelEdgeFilter ((LevelGraph ) graph ));
227
+ MiniPerfTest miniPerf = new MiniPerfTest ()
228
+ {
229
+ @ Override
230
+ public int doCalc ( boolean warmup , int run )
231
+ {
232
+ int nodeId = rand .nextInt (maxNode );
233
+ return GHUtility .count (chExplorer .setBaseNode (nodeId ));
234
+ }
235
+ }.setIterations (count ).start ();
236
+ print ("unit_testsCH.level_edge_state_next" , miniPerf );
237
+
238
+ final EdgeSkipExplorer chExplorer2 = lg .createEdgeExplorer ();
239
+ miniPerf = new MiniPerfTest ()
240
+ {
241
+ @ Override
242
+ public int doCalc ( boolean warmup , int run )
243
+ {
244
+ int nodeId = rand .nextInt (maxNode );
245
+ EdgeSkipIterator iter = chExplorer2 .setBaseNode (nodeId );
246
+ while (iter .next ())
247
+ {
248
+ if (iter .isShortcut ())
249
+ nodeId += (int ) iter .getWeight ();
250
+ }
251
+ return nodeId ;
252
+ }
253
+ }.setIterations (count ).start ();
254
+ print ("unit_testsCH.get_weight" , miniPerf );
255
+ }
213
256
214
- FlagEncoder encoder = hopper .getEncodingManager ().getEncoder (vehicle );
215
257
EdgeFilter outFilter = new DefaultEdgeFilter (encoder , false , true );
216
258
final EdgeExplorer outExplorer = graph .createEdgeExplorer (outFilter );
217
259
MiniPerfTest miniPerf = new MiniPerfTest ()
@@ -223,7 +265,7 @@ public int doCalc( boolean warmup, int run )
223
265
return GHUtility .count (outExplorer .setBaseNode (nodeId ));
224
266
}
225
267
}.setIterations (count ).start ();
226
- print ("unit_tests.out_edge_state_next" , miniPerf );
268
+ print ("unit_tests" + description + " .out_edge_state_next" , miniPerf );
227
269
228
270
final EdgeExplorer allExplorer = graph .createEdgeExplorer ();
229
271
miniPerf = new MiniPerfTest ()
@@ -235,7 +277,7 @@ public int doCalc( boolean warmup, int run )
235
277
return GHUtility .count (allExplorer .setBaseNode (nodeId ));
236
278
}
237
279
}.setIterations (count ).start ();
238
- print ("unit_tests.all_edge_state_next" , miniPerf );
280
+ print ("unit_tests" + description + " .all_edge_state_next" , miniPerf );
239
281
240
282
final int maxEdgesId = graph .getAllEdges ().getCount ();
241
283
miniPerf = new MiniPerfTest ()
@@ -251,7 +293,7 @@ public int doCalc( boolean warmup, int run )
251
293
}
252
294
}
253
295
}.setIterations (count ).start ();
254
- print ("unit_tests.get_edge_state" , miniPerf );
296
+ print ("unit_tests" + description + " .get_edge_state" , miniPerf );
255
297
}
256
298
257
299
private void printTimeOfRouteQuery ( final GraphHopper hopper , int count , String prefix ,
0 commit comments