Bridges-C++  3.4.4
Bridges(C++ API)
PageRankBenchmark.h
Go to the documentation of this file.
1 #ifndef PAGERANK_BENCHMARK_H
2 #define PAGERANK_BENCHMARK_H
3 
4 #include <LineChart.h>
5 #include <limits>
6 #include <vector>
7 #include <chrono>
8 #include <stdlib.h>
9 #include <iostream>
10 #include <GraphBenchmark.h>
11 
12 namespace bridges {
13  namespace benchmark {
14  using namespace bridges::datastructure;
41  private:
42  LineChart& plot;
43 
44  public:
46  : plot (p) {
47  p.setXLabel("Number of Edges");
48  p.setYLabel("Runtime (in s)");
49 
50  }
51 
58  void run(std::string algoName,
59  void (*pralgo)(const GraphAdjList<std::string>& gr,
60  std::unordered_map<std::string, double>& out)) {
61  std::vector<double> time;
62  std::vector<double> vtxCounts;
63  std::vector<double> edgeCounts;
64 
65  for (int years = 0; years < 120; years = 1.2 * years + 1) {
66  int year = 2019 - years;
67  std::cerr << "*" << std::flush;
69  long vertexCount;
70  long edgeCount;
71  std::tie(vertexCount, edgeCount) = generateWikidataMovieActor(year, 2019, graph);
72 
73  std::unordered_map<std::string, double> pr;
74 
75  std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
76 
77  pralgo(graph, pr);
78 
79  std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
80 
81  std::chrono::duration<double> elapsed_seconds = end - start;
82 
83  time.push_back ((double)elapsed_seconds.count() );
84  vtxCounts.push_back ( (double)vertexCount );
85  edgeCounts.push_back ( (double)edgeCount );
86 
87  if (elapsed_seconds.count() > time_cap) {
88  break;
89  }
90  }
91  plot.setXData(algoName, edgeCounts);
92  plot.setYData(algoName, time);
93  std::cerr << "\n" << std::flush;
94  }
95  };
96  }
97 }
98 
99 #endif
Base class for a variety of graph based benchmark.
Definition: GraphBenchmark.h:15
Benchmarks Page Rank algorithms.
Definition: PageRankBenchmark.h:40
void run(std::string algoName, void(*pralgo)(const GraphAdjList< std::string > &gr, std::unordered_map< std::string, double > &out))
benchmark one implementation
Definition: PageRankBenchmark.h:58
PageRankBenchmark(LineChart &p)
Definition: PageRankBenchmark.h:45
This class provides methods to represent adjacency list based graphs.
Definition: GraphAdjList.h:110
Show series of data or functions using a line chart.
Definition: LineChart.h:43
void setYData(string series, vector< double > ydata)
Changes the Y data for a series.
Definition: LineChart.h:234
void setXData(string series, vector< double > xdata)
Changes the X data for a series.
Definition: LineChart.h:214
Definition: Array.h:9
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4