GraphChi 0.1

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros
plotter.hpp
Go to the documentation of this file.
1
31 #ifndef DEF_GRAPHCHI_GNUPLOTTER
32 #define DEF_GRAPHCHI_GNUPLOTTER
33
34 #include <cstdio>
35 #include <stdlib.h>
36 #include "graphchi_basic_includes.hpp"
37
38 namespace graphchi {
39
40 static size_t initial_edges = 0;
41
42
43 static std::string plotdirectory();
44 static std::string plotdirectory() {
45 return "conf/adminhtml/plots/";}
46
47 static void init_plot(std::string plotname);
48 static void init_plot(std::string plotname) {
49 std::string dataname = plotdirectory() + plotname + ".dat";
50 FILE * df = fopen(dataname.c_str(), "w");
51 fclose(df);
52 }
53
54 template <typename ENGINE>
55 void addval(ENGINE * engine, std::string plotname, double val) {
56 graphchi_context &context = engine->get_context();
57 std::string dataname = plotdirectory() + plotname + ".dat";
58 FILE * df = fopen(dataname.c_str(), "a");
59 fprintf(df, "%lf %lf\n", context.runtime(), val);
60 fclose(df);
61
62 }
63
64 static void drawplot(std::string plotname);
65 static void drawplot(std::string plotname) {
66 std::string plotfile = plotdirectory() + plotname + ".dat";
67 std::string cmd = plotdirectory() + "plotter.py " + plotfile;
68 logstream(LOG_DEBUG) << "Executing: " << cmd << std::endl;
69 system(cmd.c_str());
70 }
71
72 template <typename ENGINE>
73 static void init_plots(ENGINE * engine) {
74 init_plot("edges");
75 init_plot("bufedges");
76 init_plot("updates");
77 init_plot("ingests");
78 initial_edges = engine->num_edges_safe();
79 }
80
81 template <typename ENGINE>
82 void update_plotdata(ENGINE * engine) {
83 addval(engine, "edges", (double)engine->num_edges_safe());
84 addval(engine, "bufedges", (double)engine->num_buffered_edges());
85 addval(engine, "ingests", (engine->num_edges_safe() - initial_edges) / engine->get_context().runtime());
86 addval(engine, "updates", engine->num_updates() / engine->get_context().runtime());
87 }
88
89 static void drawplots();
90 static void drawplots() {
91 drawplot("edges");
92 drawplot("bufedges");
93 drawplot("updates");
94 drawplot("ingests");
95 }
96
97 }
98
99 #endif