OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
vector_dist_performance_util.cpp
1 /*
2  * vector_dist_performance_util.cpp
3  *
4  * Created on: Feb 14, 2018
5  * Author: i-bird
6  */
7 
9 
10 #include "vector_dist_performance_util.hpp"
11 #include "Plot/GoogleChart.hpp"
12 
13 void addUpdtateTime(GoogleChart & cg)
14 {
15  time_t t = time(0); // get time now
16  struct tm * now = localtime( & t );
17 
18  std::stringstream str;
19 
20  str << "<h3>Updated: " << now->tm_mday << "/" << now->tm_mon + 1 << "/" << now->tm_year+1900 << " " << now->tm_hour << ":" << now->tm_min << ":" << now->tm_sec << std::endl;
21 
22  cg.addHTML(str.str());
23 }
24 
31 void StandardPerformanceGraph(std::string file_mean,
32  std::string file_var,
33  std::string file_mean_save,
34  std::string file_var_save,
35  GoogleChart & cg,
41  std::string x_string,
42  std::string y_string,
43  bool use_log)
44 {
47  y_ref_mean.load(file_mean);
48  y_ref_dev.load(file_var);
49 
50  // warning level
51  openfpm::vector<int> warning_vlevel;
52 
53  // Calculation time graphs data
54 
59 
60  if (names.size() == 0)
61  return;
62 
63  for (size_t i = 0 ; i < names.size() ; i++)
64  yn2.add(names.get(i));
65 
66  for (size_t i = 0; i < xp.size() ; i++)
67  x.add(xp.get(i));
68 
69  yp_mean.save(file_mean_save);
70  yp_dev.save(file_var_save);
71 
72  if (y_ref_mean.size() != 0 && yp_mean.size() != 0 && yp_mean.get(0).size() != 0)
73  {
74  // We reconstruct y and yn
75 
76  y2.clear();
77  yn2.clear();
78 
79  for (size_t i = 0 ; i < yp_mean.get(0).get(0).size() ; i++)
80  {
81  yn2.add(names.get(i));
82  yn2.add("interval");
83  yn2.add("interval");
84  }
85 
86  y2.resize(yp_mean.size());
87  for (size_t r = 0; r < yp_mean.size(); r++)
88  {
89  int warning_level = -1;
90 
91  y2.get(r).resize(yp_mean.get(r).size());
92  for (size_t k = 0; k < yp_mean.get(r).size(); k++)
93  {
94 
95  // Number of graph points
96  for (size_t g = 0 ; g < yp_mean.get(r).get(k).size() ; g++)
97  {
98  // Time for construction hilbert and random
99  y2.get(r).get(k).add(yp_mean.get(r).get(k).get(g));
100  y2.get(r).get(k).add(y_ref_mean.get(r).get(k).get(g) - 3.0*y_ref_dev.get(r).get(k).get(g));
101  y2.get(r).get(k).add(y_ref_mean.get(r).get(k).get(g) + 3.0*y_ref_dev.get(r).get(k).get(g));
102 
103  warning_set(warning_level,yp_mean.get(r).get(k).get(g),y_ref_mean.get(r).get(k).get(g),y_ref_dev.get(r).get(k).get(g));
104  }
105  }
106 
107  warning_vlevel.add(warning_level);
108  }
109  }
110  else
111  {
112  return;
113  }
114 
115  // Calculation time graphs report
116 
117  // Google charts options
118  GCoptions options2;
119 
120  options2.yAxis = std::string(y_string);
121  options2.xAxis = std::string(x_string);
122  options2.lineWidth = 4;
123 
124  for (size_t i = 0; i < y2.size() ; i++)
125  {
126  std::string chart_area;
127  if (warning_vlevel.size() != 0)
128  addchartarea(chart_area,warning_vlevel.get(i));
129 
130  if (use_log == true)
131  {options2.more = GC_Y_LOG + "," + GC_ZOOM + chart_area;}
132  else
133  {options2.more = GC_ZOOM + chart_area;}
134 
135  options2.title = gnames.get(i);
136  cg.AddLinesGraph(x,y2.get(i),yn2,options2);
137  }
138 }
139 
140 
void addHTML(const std::string &html)
Add HTML text.
void AddLinesGraph(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add a simple lines graph.
std::string title
Title of the chart.
Definition: GoogleChart.hpp:27
std::string more
more
Definition: GoogleChart.hpp:66
size_t size()
Stub size.
Definition: map_vector.hpp:70
std::string yAxis
Y axis name.
Definition: GoogleChart.hpp:29
Small class to produce graph with Google chart in HTML.
size_t lineWidth
Width of the line.
Definition: GoogleChart.hpp:55
std::string xAxis
X axis name.
Definition: GoogleChart.hpp:31
Google chart options.
Definition: GoogleChart.hpp:24