OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
vector_performance_test.hpp
1 /*
2  * vector_performance_test.hpp
3  *
4  * Created on: Jan 11, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_VECTOR_VECTOR_PERFORMANCE_TEST_HPP_
9 #define OPENFPM_DATA_SRC_VECTOR_VECTOR_PERFORMANCE_TEST_HPP_
10 
11 #define NADD 128*128*128
12 
14 openfpm::vector<float> per_timesv;
15 
16 BOOST_AUTO_TEST_CASE(vector_add_performance)
17 {
18  std::vector<double> times(N_STAT + 1);
19  times[0] = 1000;
20 
21  for (size_t j = 0 ; j < 8 ; j++)
22  {
23  for (size_t i = 1 ; i < N_STAT+1 ; i++)
24  {
25  timer t;
26  t.start();
27 
28  // create a vector
30 
31  // Point
33  p.setx(1.0);
34  p.sety(2.0);
35  p.setz(3.0);
36  p.sets(4.0);
37 
38  p.get<P::v>()[0] = 1.0;
39  p.get<P::v>()[1] = 2.0;
40  p.get<P::v>()[2] = 7.0;
41 
42  p.get<P::t>()[0][0] = 10.0;
43  p.get<P::t>()[0][1] = 13.0;
44  p.get<P::t>()[0][2] = 8.0;
45  p.get<P::t>()[1][0] = 19.0;
46  p.get<P::t>()[1][1] = 23.0;
47  p.get<P::t>()[1][2] = 5.0;
48  p.get<P::t>()[2][0] = 4.0;
49  p.get<P::t>()[2][1] = 3.0;
50  p.get<P::t>()[2][2] = 11.0;
51 
52  // push objects
53 
54  for (size_t i = 0 ; i < NADD ; i++)
55  {
56  v1.add(p);
57  }
58 
59  t.stop();
60  times[i] = t.getwct();
61  }
62  std::sort(times.begin(),times.end());
63 
64  sleep(5);
65  }
66 
67  testsv.add("Vector add");
68  per_timesv.add(times[0]);
69 }
70 
72 
73 BOOST_AUTO_TEST_CASE(vector_performance_write_report)
74 {
77 
78  std::cout << "Write vector report\n";
79 
80  // Get the directory of the performance test files
81  std::string per_dir(test_dir);
82 
83  load_and_combine(per_dir + std::string("/openfpm_data/previous_measurev"),y,per_timesv);
84 
85  // Adding the dataset names
86  if (y.size() != 0)
87  {
88  for (size_t j = 0; j < y.get(0).size(); j++)
89  yn.add("config " + std::to_string(j));
90  }
91 
92  // Google charts options
93  GCoptions options;
94 
95  options.title = std::string("Vector Performances");
96  options.yAxis = std::string("Time (seconds)");
97  options.xAxis = std::string("Benchmark");
98  options.stype = std::string("bars");
99 
100  cg.addHTML("<h2>Vector performance test</h2>");
101  cg.AddHistGraph(testsv,y,yn,options);
102 }
103 
104 #endif /* OPENFPM_DATA_SRC_VECTOR_VECTOR_PERFORMANCE_TEST_HPP_ */
void setz(T z_)
set the z property
Definition: Point_test.hpp:190
std::string title
Title of the chart.
Definition: GoogleChart.hpp:27
size_t size()
Stub size.
Definition: map_vector.hpp:70
double getwct()
Return the elapsed real time.
Definition: timer.hpp:108
std::string yAxis
Y axis name.
Definition: GoogleChart.hpp:29
void setx(T x_)
set the x property
Definition: Point_test.hpp:176
void start()
Start the timer.
Definition: timer.hpp:73
boost::fusion::result_of::at< type, boost::mpl::int_< i > >::type get()
getter method for a general property i
Definition: Point_test.hpp:218
void sets(T s_)
set the s property
Definition: Point_test.hpp:197
void sety(T y_)
set the y property
Definition: Point_test.hpp:183
std::string stype
Definition: GoogleChart.hpp:37
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
Definition: Point_test.hpp:149
Test structure used for several test.
Definition: Point_test.hpp:105
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
Definition: Point_test.hpp:146
std::string xAxis
X axis name.
Definition: GoogleChart.hpp:31
Google chart options.
Definition: GoogleChart.hpp:24
Class for cpu time benchmarking.
Definition: timer.hpp:25
void stop()
Stop the timer.
Definition: timer.hpp:97