OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
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.getcputime();
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("/previous_measurev"),y,per_timesv,testsv.size());
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.AddColumsGraph(testsv,y,yn,options);
102 }
103 
104 #endif /* OPENFPM_DATA_SRC_VECTOR_VECTOR_PERFORMANCE_TEST_HPP_ */
double getcputime()
Return the cpu time.
Definition: timer.hpp:114
void start()
Start the timer.
Definition: timer.hpp:67
Test structure used for several test.
Definition: Point_test.hpp:72
Implementation of 1-D std::vector like structure.
Definition: map_grid.hpp:94
Class for cpu time benchmarking.
Definition: timer.hpp:25
void stop()
Stop the timer.
Definition: timer.hpp:91