1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.benchmark; |
20 | |
|
21 | |
import org.apache.commons.cli.CommandLine; |
22 | |
import org.apache.giraph.combiner.MinimumDoubleMessageCombiner; |
23 | |
import org.apache.giraph.conf.GiraphConfiguration; |
24 | |
import org.apache.giraph.conf.GiraphConstants; |
25 | |
import org.apache.giraph.edge.ArrayListEdges; |
26 | |
import org.apache.giraph.edge.HashMapEdges; |
27 | |
import org.apache.giraph.io.formats.PseudoRandomInputFormatConstants; |
28 | |
import org.apache.giraph.io.formats.PseudoRandomVertexInputFormat; |
29 | |
import org.apache.hadoop.util.ToolRunner; |
30 | |
import org.apache.log4j.Logger; |
31 | |
|
32 | |
import com.google.common.collect.Sets; |
33 | |
|
34 | |
import java.util.Set; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class ShortestPathsBenchmark extends GiraphBenchmark { |
40 | |
|
41 | 0 | private static final Logger LOG = |
42 | 0 | Logger.getLogger(ShortestPathsBenchmark.class); |
43 | |
|
44 | |
|
45 | 0 | private static final BenchmarkOption EDGES_CLASS = new BenchmarkOption( |
46 | |
"c", "edgesClass", true, |
47 | |
"Vertex edges class (0 for HashMapEdges, 1 for ArrayListEdges)"); |
48 | |
|
49 | 0 | private static final BenchmarkOption NO_COMBINER = new BenchmarkOption( |
50 | |
"nc", "noCombiner", false, "Don't use a combiner"); |
51 | |
|
52 | |
@Override |
53 | |
public Set<BenchmarkOption> getBenchmarkOptions() { |
54 | 0 | return Sets.newHashSet(BenchmarkOption.VERTICES, |
55 | |
BenchmarkOption.EDGES_PER_VERTEX, EDGES_CLASS, NO_COMBINER); |
56 | |
} |
57 | |
|
58 | |
@Override |
59 | |
protected void prepareConfiguration(GiraphConfiguration conf, |
60 | |
CommandLine cmd) { |
61 | 0 | conf.setComputationClass(ShortestPathsComputation.class); |
62 | 0 | if (EDGES_CLASS.getOptionIntValue(cmd, 1) == 1) { |
63 | 0 | conf.setOutEdgesClass(ArrayListEdges.class); |
64 | |
} else { |
65 | 0 | conf.setOutEdgesClass(HashMapEdges.class); |
66 | |
} |
67 | 0 | LOG.info("Using class " + GiraphConstants.COMPUTATION_CLASS.get(conf)); |
68 | 0 | conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class); |
69 | 0 | if (!NO_COMBINER.optionTurnedOn(cmd)) { |
70 | 0 | conf.setMessageCombinerClass(MinimumDoubleMessageCombiner.class); |
71 | |
} |
72 | 0 | conf.setLong(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES, |
73 | 0 | BenchmarkOption.VERTICES.getOptionLongValue(cmd)); |
74 | 0 | conf.setLong(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX, |
75 | 0 | BenchmarkOption.EDGES_PER_VERTEX.getOptionLongValue(cmd)); |
76 | 0 | } |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
public static void main(final String[] args) throws Exception { |
85 | 0 | System.exit(ToolRunner.run(new ShortestPathsBenchmark(), args)); |
86 | 0 | } |
87 | |
} |