Coverage Report - org.apache.giraph.benchmark.ShortestPathsBenchmark
 
Classes in this File Line Coverage Branch Coverage Complexity
ShortestPathsBenchmark
0%
0/21
0%
0/4
1.667
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 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  
  * Single-source shortest paths benchmark.
 38  
  */
 39  0
 public class ShortestPathsBenchmark extends GiraphBenchmark {
 40  
   /** Class logger */
 41  0
   private static final Logger LOG =
 42  0
       Logger.getLogger(ShortestPathsBenchmark.class);
 43  
 
 44  
   /** Option for OutEdges class */
 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  
   /** Option for not using combiner */
 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  
    * Execute the benchmark.
 80  
    *
 81  
    * @param args Typically the command line arguments.
 82  
    * @throws Exception Any exception from the computation.
 83  
    */
 84  
   public static void main(final String[] args) throws Exception {
 85  0
     System.exit(ToolRunner.run(new ShortestPathsBenchmark(), args));
 86  0
   }
 87  
 }