GraphChi 0.1

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros
basic_reporter.hpp
Go to the documentation of this file.
1
32 #ifndef GRAPHCHI_BASIC_REPORTER
33 #define GRAPHCHI_BASIC_REPORTER
34
35 #include <iostream>
36 #include <map>
37
38 #include "metrics/metrics.hpp"
39
45 namespace graphchi {
46
47 class basic_reporter : public imetrics_reporter {
48
49 public:
50 virtual ~basic_reporter() {}
51 virtual void do_report(std::string name, std::string ident, std::map<std::string, metrics_entry> & entries) {
52 // TODO: use reporters
53 if (ident != name) {
54 std::cout << std::endl << " === REPORT FOR " << name << "(" << ident << ") ===" << std::endl;
55 } else {
56 std::cout << std::endl << " === REPORT FOR " << name << " ===" << std::endl;
57 }
58
59 // First write numeral, then timings, then string entries
60 for(int round=0; round<4; round++) {
61 std::map<std::string, metrics_entry>::iterator it;
62 int c = 0;
63
64 for(it = entries.begin(); it != entries.end(); ++it) {
65 metrics_entry ent = it->second;
66 switch(ent.valtype) {
67 case REAL:
68 case INTEGER:
69 if (round == 0) {
70 if (c++ == 0) std::cout << "[Numeric]" << std::endl;
71 std::cout << it->first << ":\t\t";
72 if (ent.count > 1) {
73 std::cout << ent.value << "\t(count: " << ent.count << ", min: " << ent.minvalue <<
74 ", max: " << ent.maxvalue << ", avg: "
75 << ent.cumvalue/(double)ent.count << ")" << std::endl;
76 } else {
77 std::cout << ent.value << std::endl;
78 }
79 }
80 break;
81 case TIME:
82 if (round == 1) {
83 if (c++ == 0) std::cout << "[Timings]" << std::endl;
84 std::cout << it->first << ":\t\t";
85 if (ent.count>1) {
86 std::cout << ent.value << "s\t (count: " << ent.count << ", min: " << ent.minvalue <<
87 "s, " << "max: " << ent.maxvalue << ", avg: "
88 << ent.cumvalue/(double)ent.count << "s)" << std::endl;
89 } else {
90 std::cout << ent.value << " s" << std::endl;
91 }
92 }
93 break;
94 case STRING:
95 if (round == 2) {
96 if (c++ == 0) std::cout << "[Other]" << std::endl;
97 std::cout << it->first << ":\t";
98 std::cout << ent.stringval << std::endl;
99 }
100 break;
101 case VECTOR:
102 if (round == 3) {
103 if (c++ == 0) std::cout << "[Numeric]" << std::endl;
104 std::cout << it->first << ":\t\t";
105 if (ent.count > 1) {
106 std::cout << ent.value << "\t(count: " << ent.count << ", min: " << ent.minvalue <<
107 ", max: " << ent.maxvalue << ", avg: "
108 << ent.cumvalue/(double)ent.count << ")" << std::endl;
109 } else {
110 std::cout << ent.value << std::endl;
111 }
112 std::cout << it->first << ".values:\t\t";
113 for(size_t j=0; j<ent.v.size(); j++) std::cout << ent.v[j] << ",";
114 std::cout << std::endl;
115 }
116 break;
117 }
118 }
119 }
120 };
121
122 };
123
124 };
125
126
127
128 #endif
129