30 #ifndef DEF_GRAPHCHI_FILE_REPORTER
31 #define DEF_GRAPHCHI_FILE_REPORTER
43 class file_reporter :
public imetrics_reporter {
52 file_reporter(std::string fname) : filename(fname) {
54 f = fopen(fname.c_str(),
"w");
58 virtual ~file_reporter() {}
60 virtual void do_report(std::string name, std::string ident, std::map<std::string, metrics_entry> & entries) {
62 fprintf(f,
"[%s:%s]\n", name.c_str(), ident.c_str());
64 fprintf(f,
"[%s]\n", name.c_str());
66 std::map<std::string, metrics_entry>::iterator it;
68 for(it = entries.begin(); it != entries.end(); ++it) {
69 metrics_entry ent = it->second;
73 fprintf(f,
"%s.%s=%ld\n", ident.c_str(), it->first.c_str(), (
long int) (ent.value));
74 fprintf(f,
"%s.%s.count=%lu\n", ident.c_str(), it->first.c_str(), ent.count);
75 fprintf(f,
"%s.%s.min=%ld\n", ident.c_str(), it->first.c_str(), (
long int) (ent.minvalue));
76 fprintf(f,
"%s.%s.max=%ld\n", ident.c_str(), it->first.c_str(), (
long int) (ent.maxvalue));
77 fprintf(f,
"%s.%s.avg=%lf\n", ident.c_str(), it->first.c_str(), ent.cumvalue/ent.count);
81 fprintf(f,
"%s.%s=%lf\n", ident.c_str(), it->first.c_str(), (ent.value));
82 fprintf(f,
"%s.%s.count=%lu\n", ident.c_str(), it->first.c_str(), ent.count);
83 fprintf(f,
"%s.%s.min=%lf\n", ident.c_str(), it->first.c_str(), (ent.minvalue));
84 fprintf(f,
"%s.%s.max=%lf\n", ident.c_str(), it->first.c_str(), (ent.maxvalue));
85 fprintf(f,
"%s.%s.avg=%lf\n", ident.c_str(), it->first.c_str(), ent.cumvalue/ent.count);
88 fprintf(f,
"%s.%s=%s\n", ident.c_str(), it->first.c_str(), it->second.stringval.c_str());