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