Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
RCP_Performance_UnitTests.cpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Teuchos: Common Tools Package
6 // Copyright (2004) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
45 #include "Teuchos_RCP.hpp"
47 
48 #ifdef HAVE_TEUCHOS_BOOST
49 # include "boost/shared_ptr.hpp"
50 #endif
51 
52 
53 namespace {
54 
55 
56 using Teuchos::null;
57 using Teuchos::RCP;
58 using Teuchos::rcp;
60 
61 
62 double relCpuSpeed = 1e-2;
63 int maxArraySize = 10000;
64 double maxRcpRawCreateDestroyRatio = 10.0;
65 double maxRcpRawAdjustRefCountRatio = 100.0;
66 double maxRcpSpAdjustRefCountRatio = 5.0;
67 double maxRcpRawObjAccessRatio = 13.5;
68 
69 const int intPrec = 8;
70 const int dblPrec = 6;
71 
72 
74 {
77  clp.setOption(
78  "rel-cpu-speed", &relCpuSpeed,
79  "The relative speed of the CPU (higher means the machine runs faster)"
80  );
81  clp.setOption(
82  "max-array-size", &maxArraySize,
83  "The maximum size of the arrays created"
84  );
85  clp.setOption(
86  "max-rcp-create-destroy-ratio", &maxRcpRawCreateDestroyRatio,
87  "The ratio of the final CPU time ratio of creating and destroying"
88  "std::vector<char>(size) objects wrapped in an RCP object versus"
89  "using just raw new and delete."
90  );
91  clp.setOption(
92  "max-rcp-raw-adjust-ref-count-ratio", &maxRcpRawAdjustRefCountRatio,
93  "The ratio of the final CPU time ratio for adjusting the reference"
94  "count of RCP objects versus a raw pointer."
95  );
96  clp.setOption(
97  "max-rcp-sp-adjust-ref-count-ratio", &maxRcpSpAdjustRefCountRatio,
98  "The ratio of the final CPU time ratio for adjusting the reference"
99  "count of RCP objects versus boost::shared_ptr objects."
100  );
101  clp.setOption(
102  "max-rcp-raw-obj-access-ratio", &maxRcpRawObjAccessRatio,
103  "The ratio of the final CPU time ratio for accessing the object for RCP"
104  "versus a raw pointer."
105  );
106 
107 }
108 
109 
110 template<typename T>
111 struct DeleteDeleter {};
112 
113 
114 TEUCHOS_UNIT_TEST( RCP, _sizeofObjects )
115 {
116  out << "\nPrinting the size the RCP and RCPNodeImpl objects ...\n";
117  TEST_INEQUALITY_CONST(sizeof(bool), 0);
118  TEST_INEQUALITY_CONST(sizeof(double), 0);
119  TEST_INEQUALITY_CONST(sizeof(double*), 0);
120  TEST_INEQUALITY_CONST(sizeof(std::vector<double>), 0);
124  TEST_INEQUALITY_CONST(sizeof(Teuchos::RCP<std::vector<double> >), 0);
126  sizeof(Teuchos::RCPNodeTmpl<std::vector<double>,
127  Teuchos::DeallocDelete<std::vector<double> > >),
128  0);
129 #ifdef HAVE_TEUCHOS_BOOST
130  TEST_INEQUALITY_CONST(sizeof(boost::detail::shared_count), 0);
131  TEST_INEQUALITY_CONST(sizeof(boost::shared_ptr<std::vector<double> >), 0);
132  TEST_INEQUALITY_CONST(sizeof(boost::detail::sp_counted_impl_p<std::vector<double> >), 0);
134  sizeof(boost::detail::sp_counted_impl_pd<std::vector<double>,
135  DeleteDeleter<std::vector<double> > >),
136  0);
137 #endif
138 }
139 
140 
141 TEUCHOS_UNIT_TEST( RCP, createDestroyOverhead )
142 {
143 
144  typedef Teuchos::TabularOutputter TO;
145 
146  const int maxLoopIters = 1000;
147  const double relTestCost = 1e-3;
148  const double numInnerLoops = relCpuSpeed / relTestCost;
149 
150  out << "\n"
151  << "Messuring the overhead of creating and destorying objects of different sizes\n"
152  << "using raw C++ pointers, shared_ptr, and using RCP.\n"
153  << "\n"
154  << "Number of loops = relCpuSpeed/relTestCost = "
155  << relCpuSpeed << "/" << relTestCost << " = " << numInnerLoops << "\n"
156  << "\n";
157 
158  TabularOutputter outputter(out);
159  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
160  outputter.setFieldTypePrecision(TO::INT, intPrec);
161 
162  outputter.pushFieldSpec("obj size", TO::INT);
163  outputter.pushFieldSpec("num loops", TO::INT);
164  outputter.pushFieldSpec("raw", TO::DOUBLE);
165 #ifdef HAVE_TEUCHOS_BOOST
166  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
167 #endif
168  outputter.pushFieldSpec("RCP", TO::DOUBLE);
169 #ifdef HAVE_TEUCHOS_BOOST
170  outputter.pushFieldSpec("shared_ptr/raw", TO::DOUBLE);
171 #endif
172  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
173 
174  outputter.outputHeader();
175 
176  double finalRcpRawRatio = 100000.0;
177 
178  int arraySize = 1;
179  for (int test_case_k = 0;
180  test_case_k < maxLoopIters && arraySize <= maxArraySize;
181  ++test_case_k
182  )
183  {
184 
185  // obj size
186  outputter.outputField(arraySize);
187 
188  // num loops
189  const int numActualLoops =
190  TEUCHOS_MAX(
191  static_cast<int>(
192  (numInnerLoops / arraySize)
193  * std::log(static_cast<double>(arraySize+1))
194  ),
195  1
196  );
197  outputter.outputField(numActualLoops);
198 
199  // raw
200  {
201  std::vector<std::vector<char>*> p_raw_vec(numActualLoops);
202  int i = 0;
203  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
204  {
205  p_raw_vec[i] = new std::vector<char>(arraySize, 1);
206  delete p_raw_vec[i];
207  ++i;
208  }
209  }
210  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
211 
212 #ifdef HAVE_TEUCHOS_BOOST
213  // shared_ptr
214  {
215  typedef boost::shared_ptr<std::vector<char> > shared_ptr_t;
216  std::vector<shared_ptr_t > sp_vec(numActualLoops);
217  int i = 0;
218  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
219  {
220  sp_vec[i] = shared_ptr_t(new std::vector<char>(arraySize, 1));
221  sp_vec[i].reset();
222  ++i;
223  }
224  }
225  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
226 #endif
227 
228  // RCP
229  {
230  std::vector<RCP<std::vector<char> > > p_vec(numActualLoops);
231  int i = 0;
232  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
233  {
234  p_vec[i] = rcp(new std::vector<char>(arraySize, 1));
235  p_vec[i] = null;
236  }
237  }
238  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
239 
240 #ifdef HAVE_TEUCHOS_BOOST
241  // shared_ptr/rawPtr
242  const double spRatio = spTime / rawPtrTime;
243  outputter.outputField(spRatio);
244 #endif
245 
246  // RCP/rawPtr
247  const double rcpRatio = rcpTime / rawPtrTime;
248  outputter.outputField(rcpRatio);
249 
250  outputter.nextRow();
251 
252  arraySize *= 4;
253  finalRcpRawRatio = TEUCHOS_MIN(rcpRatio, finalRcpRawRatio);
254 
255  }
256 
257  out << "\n";
258  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawCreateDestroyRatio );
259  out << "\n";
260 
261 }
262 
263 
264 TEUCHOS_UNIT_TEST( RCP, referenceCountManipulationOverhead )
265 {
266 
267  typedef Teuchos::TabularOutputter TO;
268 
269  const double relTestCost = 5e-3;
270  const int maxLoopIters = 1000;
271  const double numInnerLoops = relCpuSpeed / relTestCost;
272 
273  out << "\n"
274  << "Messuring the overhead of incrementing and deincrementing the reference count\n"
275  << "comparing RCP to raw pointer and boost::shared_ptr.\n"
276  << "\n";
277 
278  TabularOutputter outputter(out);
279  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
280  outputter.setFieldTypePrecision(TO::INT, intPrec);
281 
282  outputter.pushFieldSpec("array dim", TO::INT);
283  outputter.pushFieldSpec("num loops", TO::INT);
284  outputter.pushFieldSpec("raw", TO::DOUBLE);
285  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
286  outputter.pushFieldSpec("RCP", TO::DOUBLE);
287  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
288  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
289 
290  outputter.outputHeader();
291 
292  double finalRcpRawRatio = 100000.0;
293  double finalRcpSpRatio = 100000.0;
294  int arraySize = 64;
295 
296  for (
297  int test_case_k = 0;
298  test_case_k < maxLoopIters && arraySize <= maxArraySize;
299  ++test_case_k
300  )
301  {
302 
303  // array dim
304  outputter.outputField(arraySize);
305 
306  // num loops
307  const int numActualLoops =
308  TEUCHOS_MAX(
309  static_cast<int>(
310  (numInnerLoops / arraySize)
311  * std::log(static_cast<double>(arraySize+1))
312  ),
313  1
314  );
315  outputter.outputField(numActualLoops);
316 
317  // raw
318  {
319  char dummy_char = 'n';
320  std::vector<char*> p_raw_vec(arraySize);
321  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
322  {
323  for (int i=0; i < arraySize; ++i) {
324  p_raw_vec[i] = &dummy_char;
325  }
326  }
327  }
328  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
329 
330 #ifdef HAVE_TEUCHOS_BOOST
331  // shared_ptr
332  {
333  typedef boost::shared_ptr<char> shared_ptr_t;
334  shared_ptr_t sp(new char('n'));
335  std::vector<shared_ptr_t> sp_vec(arraySize);
336  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
337  {
338  for (int i=0; i < arraySize; ++i) {
339  sp_vec[i] = sp;
340  }
341  }
342  }
343  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
344 #else
345  outputter.outputField("-");
346 #endif
347 
348  // RCP
349  {
350  RCP<char> p(new char('n'));
351  std::vector<RCP<char> > p_vec(arraySize);
352  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
353  {
354  for (int i=0; i < arraySize; ++i) {
355  p_vec[i] = p;
356  // NOTE: This assignment operation tests the copy constructor and
357  // the swap function. This calls both bind() and unbind()
358  // underneath.
359  }
360  }
361  }
362  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
363 
364  // RCP/raw
365  const double rcpRawRatio = rcpTime / rawPtrTime;
366  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
367  outputter.outputField(rcpRawRatio);
368 
369 #ifdef HAVE_TEUCHOS_BOOST
370  // RCP/shared_ptr
371  const double rcpSpRatio = rcpTime / spTime;
372  finalRcpSpRatio = TEUCHOS_MIN(rcpSpRatio, finalRcpSpRatio);
373  outputter.outputField(rcpSpRatio);
374 #else
375  outputter.outputField("-");
376 #endif
377 
378  outputter.nextRow();
379 
380  arraySize *= 4;
381 
382  }
383 
384  out << "\n";
385  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawAdjustRefCountRatio );
386 #ifdef HAVE_TEUCHOS_BOOST
387  out << "\n";
388  TEST_COMPARE( finalRcpSpRatio, <=, maxRcpSpAdjustRefCountRatio );
389  out << "\n";
390 #else
391  (void)finalRcpSpRatio;
392 #endif
393 
394 }
395 
396 
397 TEUCHOS_UNIT_TEST( RCP, dereferenceOverhead )
398 {
399 
400  typedef Teuchos::TabularOutputter TO;
401 
402  const double relTestCost = 1e-4;
403  const int maxLoopIters = 1000;
404  const double numInnerLoops = relCpuSpeed / relTestCost;
405 
406  out << "\n"
407  << "Messuring the overhead of dereferencing RCP, shared_ptr and a raw pointer.\n"
408  << "\n";
409 
410  TabularOutputter outputter(out);
411  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
412  outputter.setFieldTypePrecision(TO::INT, intPrec);
413 
414  outputter.pushFieldSpec("array dim", TO::INT);
415  outputter.pushFieldSpec("num loops", TO::INT);
416  outputter.pushFieldSpec("raw", TO::DOUBLE);
417  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
418  outputter.pushFieldSpec("RCP", TO::DOUBLE);
419  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
420  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
421 
422  outputter.outputHeader();
423 
424  double finalRcpRawRatio = 100000.0;
425  int arraySize = 64;
426  const int dummy_int_val = 1;
427  int overall_dummy_int_out = 0;
428 
429 
430  for (
431  int test_case_k = 0;
432  test_case_k < maxLoopIters && arraySize <= maxArraySize;
433  ++test_case_k
434  )
435  {
436 
437  // array dim
438  outputter.outputField(arraySize);
439 
440  // num loops
441  const int numActualLoops =
442  TEUCHOS_MAX(
443  static_cast<int>(
444  (numInnerLoops / arraySize)
445  * std::log(static_cast<double>(arraySize+1))
446  ),
447  1
448  );
449  outputter.outputField(numActualLoops);
450 
451  int dummy_int_out = 0;
452 
453  // raw
454  {
455  int dummy_int = dummy_int_val;
456  std::vector<int*> p_raw_vec(arraySize);
457  for (int i=0; i < arraySize; ++i) {
458  p_raw_vec[i] = &dummy_int;
459  }
460  dummy_int_out = 0;
461  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
462  {
463  for (int i=0; i < arraySize; ++i) {
464  dummy_int_out += *p_raw_vec[i];
465  }
466  }
467  }
468  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
469  overall_dummy_int_out += dummy_int_out;
470 
471  // shared_ptr
472 #ifdef HAVE_TEUCHOS_BOOST
473  {
474  typedef boost::shared_ptr<int> shared_ptr_t;
475  shared_ptr_t sp(new int(dummy_int_val));
476  std::vector<shared_ptr_t> sp_vec(arraySize);
477  for (int i=0; i < arraySize; ++i) {
478  sp_vec[i] = sp;
479  }
480  dummy_int_out = 0;
481  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
482  {
483  for (int i=0; i < arraySize; ++i) {
484  dummy_int_out += *sp_vec[i];
485  }
486  }
487  }
488  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
489  overall_dummy_int_out += dummy_int_out;
490 #else
491  outputter.outputField("-");
492 #endif
493 
494  // RCP
495  {
496  RCP<int> p(new int(dummy_int_val));
497  std::vector<RCP<int> > p_vec(arraySize);
498  for (int i=0; i < arraySize; ++i) {
499  p_vec[i] = p;
500  }
501  dummy_int_out = 0;
502  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
503  {
504  for (int i=0; i < arraySize; ++i) {
505  dummy_int_out += *p_vec[i];
506  }
507  }
508  }
509  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
510  overall_dummy_int_out += dummy_int_out;
511 
512  // RCP/raw
513  const double rcpRawRatio = rcpTime / rawPtrTime;
514  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
515  outputter.outputField(rcpRawRatio);
516 
517 #ifdef HAVE_TEUCHOS_BOOST
518  // RCP/shared_ptr
519  const double rcpSpRatio = rcpTime / spTime;
520  outputter.outputField(rcpSpRatio);
521 #else
522  outputter.outputField("-");
523 #endif
524 
525  outputter.nextRow();
526 
527  arraySize *= 4;
528 
529  }
530 
531  out << "\n";
532  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawObjAccessRatio );
533  out << "\n";
534 
535  // This silly variable must be accumulated or compilers like MSVC++ will
536  // optimize away the loops!
537  if (overall_dummy_int_out == 0)
538  success = false;
539 
540 }
541 
542 
543 struct SomeStruct {
544  SomeStruct(int member_in) : member(member_in) {}
545  int member;
546 };
547 
548 
549 TEUCHOS_UNIT_TEST( RCP, memberAccessOverhead )
550 {
551 
552  typedef Teuchos::TabularOutputter TO;
553 
554  const double relTestCost = 1e-4;
555  const int maxLoopIters = 1000;
556  const double numInnerLoops = relCpuSpeed / relTestCost;
557 
558  out << "\n"
559  << "Messuring the overhead of dereferencing RCP, shared_ptr and a raw pointer.\n"
560  << "\n";
561 
562  TabularOutputter outputter(out);
563  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
564  outputter.setFieldTypePrecision(TO::INT, intPrec);
565 
566  outputter.pushFieldSpec("array dim", TO::INT);
567  outputter.pushFieldSpec("num loops", TO::INT);
568  outputter.pushFieldSpec("raw", TO::DOUBLE);
569  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
570  outputter.pushFieldSpec("RCP", TO::DOUBLE);
571  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
572  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
573 
574  outputter.outputHeader();
575 
576  double finalRcpRawRatio = 100000.0;
577  int arraySize = 64;
578  const int dummy_int_val = 1;
579  int overall_dummy_int_out = 0;
580 
581  for (
582  int test_case_k = 0;
583  test_case_k < maxLoopIters && arraySize <= maxArraySize;
584  ++test_case_k
585  )
586  {
587 
588  // array dim
589  outputter.outputField(arraySize);
590 
591  // num loops
592  const int numActualLoops =
593  TEUCHOS_MAX(
594  static_cast<int>(
595  (numInnerLoops / arraySize)
596  * std::log(static_cast<double>(arraySize+1))
597  ),
598  1
599  );
600  outputter.outputField(numActualLoops);
601 
602  int dummy_int_out = 0;
603 
604  // raw
605  {
606  SomeStruct dummy_SomeStruct(dummy_int_val);
607  std::vector<SomeStruct*> p_raw_vec(arraySize);
608  for (int i=0; i < arraySize; ++i) {
609  p_raw_vec[i] = &dummy_SomeStruct;
610  }
611  dummy_int_out = 0;
612  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
613  {
614  for (int i=0; i < arraySize; ++i) {
615  dummy_int_out += p_raw_vec[i]->member;
616  }
617  }
618  }
619  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
620  overall_dummy_int_out += dummy_int_out;
621 
622  // shared_ptr
623 #ifdef HAVE_TEUCHOS_BOOST
624  {
625  typedef boost::shared_ptr<SomeStruct> shared_ptr_t;
626  shared_ptr_t sp(new SomeStruct(dummy_int_val));
627  std::vector<shared_ptr_t> sp_vec(arraySize);
628  for (int i=0; i < arraySize; ++i) {
629  sp_vec[i] = sp;
630  }
631  dummy_int_out = 0;
632  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
633  {
634  for (int i=0; i < arraySize; ++i) {
635  dummy_int_out += sp_vec[i]->member;
636  }
637  }
638  }
639  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
640  overall_dummy_int_out += dummy_int_out;
641 #else
642  outputter.outputField("-");
643 #endif
644 
645  // RCP
646  {
647  RCP<SomeStruct> p(new SomeStruct(dummy_int_val));
648  std::vector<RCP<SomeStruct> > p_vec(arraySize);
649  for (int i=0; i < arraySize; ++i) {
650  p_vec[i] = p;
651  }
652  dummy_int_out = 0;
653  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
654  {
655  for (int i=0; i < arraySize; ++i) {
656  dummy_int_out += p_vec[i]->member;
657  }
658  }
659  }
660  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
661  overall_dummy_int_out += dummy_int_out;
662 
663  // RCP/raw
664  const double rcpRawRatio = rcpTime / rawPtrTime;
665  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
666  outputter.outputField(rcpRawRatio);
667 
668 #ifdef HAVE_TEUCHOS_BOOST
669  // RCP/shared_ptr
670  const double rcpSpRatio = rcpTime / spTime;
671  outputter.outputField(rcpSpRatio);
672 #else
673  outputter.outputField("-");
674 #endif
675 
676  outputter.nextRow();
677 
678  arraySize *= 4;
679 
680  }
681 
682  out << "\n";
683  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawObjAccessRatio );
684  out << "\n";
685 
686  // This silly variable must be accumulated or compilers like MSVC++ will
687  // optimize away the loops!
688  if (overall_dummy_int_out == 0)
689  success = false;
690 
691 }
692 
693 
694 
695 
696 
697 
698 
699 } // namespace
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
ERCPStrength
Used to specify if the pointer is weak or strong.
#define TEST_INEQUALITY_CONST(v1, v2)
Assert the inequality of v1 and constant v2.
static CommandLineProcessor & getCLP()
Return the CLP to add options to.
#define TEST_COMPARE(v1, comp, v2)
Assert that v1 comp v2 (where comp = &#39;==&#39;, &#39;>=", "!=", etc).
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
Utility class that makes it easy to create formatted tables of output.
Policy class for deallocator that uses delete to delete a pointer which is used by RCP...
Node class to keep track of address and the reference count for a reference-counted utility class and...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
Templated implementation class of RCPNode that has the responsibility for deleting the reference-coun...
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
Unit testing support.
#define TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(OUTPUTTER, NUMLOOPS, NUMINNERLOOPS)
Start a timer block using a TabularOutputter object .
#define TEUCHOS_END_PERF_OUTPUT_TIMER(OUTPUTTER, VARNAME)
End a timer block, output the time field to a TabularOutputter object, and set a variable with the ti...
#define TEUCHOS_MAX(x, y)
Handle class that manages the RCPNode&#39;s reference counting.
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_START_PERF_OUTPUT_TIMER(OUTPUTTER, NUMLOOPS)
Start a timer block using a TabularOutputter object .
#define TEUCHOS_MIN(x, y)
Reference-counted pointer class and non-member templated function implementations.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
TEUCHOS_STATIC_SETUP()