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 public class ShortestPathsBenchmark extends GiraphBenchmark {
40
41 private static final Logger LOG =
42 Logger.getLogger(ShortestPathsBenchmark.class);
43
44
45 private static final BenchmarkOption EDGES_CLASS = new BenchmarkOption(
46 "c", "edgesClass", true,
47 "Vertex edges class (0 for HashMapEdges, 1 for ArrayListEdges)");
48
49 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 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 conf.setComputationClass(ShortestPathsComputation.class);
62 if (EDGES_CLASS.getOptionIntValue(cmd, 1) == 1) {
63 conf.setOutEdgesClass(ArrayListEdges.class);
64 } else {
65 conf.setOutEdgesClass(HashMapEdges.class);
66 }
67 LOG.info("Using class " + GiraphConstants.COMPUTATION_CLASS.get(conf));
68 conf.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
69 if (!NO_COMBINER.optionTurnedOn(cmd)) {
70 conf.setMessageCombinerClass(MinimumDoubleMessageCombiner.class);
71 }
72 conf.setLong(PseudoRandomInputFormatConstants.AGGREGATE_VERTICES,
73 BenchmarkOption.VERTICES.getOptionLongValue(cmd));
74 conf.setLong(PseudoRandomInputFormatConstants.EDGES_PER_VERTEX,
75 BenchmarkOption.EDGES_PER_VERTEX.getOptionLongValue(cmd));
76 }
77
78
79
80
81
82
83
84 public static void main(final String[] args) throws Exception {
85 System.exit(ToolRunner.run(new ShortestPathsBenchmark(), args));
86 }
87 }