-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerfChecker.cpp
87 lines (63 loc) · 2.21 KB
/
PerfChecker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Created by Бушев Дмитрий on 09.05.2021.
//
#include "GraphGenerator.h"
#include "FordAlgo.h"
#include <iostream>
#include <chrono>
void printUsage(){
std::cout << "Usage: PerfChecker <thread count[1, 12]> <max graph size[1, 32]> <sparsity[1, 32]>" << std::endl;
}
int main(int argc, char** argv){
if(argc != 4){
printUsage();
return 0;
}
int maxN, sparsity;
num_threads = std::stoi(argv[1]);
maxN = std::stoi(argv[2]);
sparsity = std::stoi(argv[3]);
if(num_threads < 1 || num_threads > 12){
std::cout << "Wrong thread count" << std::endl;
printUsage();
return 0;
}
if(maxN < 1 || maxN > 32){
std::cout << "Wrong max graph size" << std::endl;
printUsage();
return 0;
}
if(sparsity < 1 || sparsity > 32){
std::cout << "Wrong sparsity" << std::endl;
printUsage();
return 0;
}
int graphSize = 2;
std::cout << "Initialize tests with " << num_threads << " threads active, sparsity of all graphs = " << sparsity
<< std::endl;
Graph::Vid s = 1;
std::vector<std::pair<int, double>> results;
for(int i = 0; i < maxN; i++){
Graph graph;
std::cout << "Vertex count " << graphSize << " graph in calculation...";
generate(graph, graphSize, sparsity);
auto tStart = std::chrono::high_resolution_clock::now();
auto dists = fordAlgorithmJustDistance(s, graph);
auto tEnd = std::chrono::high_resolution_clock::now();
auto frameTime = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
results.emplace_back(graphSize, frameTime);
std::cout << "Done! Time elapsed: " << frameTime << "ms" << std::endl;
std::cout << "Dist map for " << s << ": ";
for(auto& dist: dists){
std::cout << dist.first << "(" << dist.second << ") ";
}
std::cout << std::endl << std::endl;
graphSize <<= 1u;
}
std::cout << "Perf check finished. results:" << std::endl;
std::cout << "Vertex count : time elapsed" << std::endl;
for(auto& res: results){
std::cout << res.first << " : " << res.second << "ms" << std::endl;
}
return 0;
}