31 #ifndef DEF_GRAPHCHI_GNUPLOTTER
32 #define DEF_GRAPHCHI_GNUPLOTTER
40 static size_t initial_edges = 0;
43 static std::string plotdirectory();
44 static std::string plotdirectory() {
45 return "conf/adminhtml/plots/";}
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");
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);
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;
72 template <
typename ENGINE>
73 static void init_plots(ENGINE * engine) {
75 init_plot(
"bufedges");
78 initial_edges = engine->num_edges_safe();
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());
89 static void drawplots();
90 static void drawplots() {