Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RCP_Performance_UnitTests.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 #include "Teuchos_RCP.hpp"
13 #ifdef HAVE_TEUCHOSCORE_CXX11
14 # include <memory>
15 #endif // HAVE_TEUCHOSCORE_CXX11
16 
17 namespace {
18 
19 
20 using Teuchos::null;
21 using Teuchos::RCP;
22 using Teuchos::rcp;
24 
25 
26 double relCpuSpeed = 1e-2;
27 int maxArraySize = 10000;
28 double maxRcpRawCreateDestroyRatio = 10.0;
29 double maxRcpRawAdjustRefCountRatio = 100.0;
30 #ifdef HAVE_TEUCHOSCORE_CXX11
31 double maxRcpSpAdjustRefCountRatio = 5.0;
32 #endif
33 double maxRcpRawObjAccessRatio = 13.5;
34 
35 const int intPrec = 8;
36 const int dblPrec = 6;
37 
38 
40 {
43  clp.setOption(
44  "rel-cpu-speed", &relCpuSpeed,
45  "The relative speed of the CPU (higher means the machine runs faster)"
46  );
47  clp.setOption(
48  "max-array-size", &maxArraySize,
49  "The maximum size of the arrays created"
50  );
51  clp.setOption(
52  "max-rcp-create-destroy-ratio", &maxRcpRawCreateDestroyRatio,
53  "The ratio of the final CPU time ratio of creating and destroying"
54  "std::vector<char>(size) objects wrapped in an RCP object versus"
55  "using just raw new and delete."
56  );
57  clp.setOption(
58  "max-rcp-raw-adjust-ref-count-ratio", &maxRcpRawAdjustRefCountRatio,
59  "The ratio of the final CPU time ratio for adjusting the reference"
60  "count of RCP objects versus a raw pointer."
61  );
62 #ifdef HAVE_TEUCHOSCORE_CXX11
63  clp.setOption(
64  "max-rcp-sp-adjust-ref-count-ratio", &maxRcpSpAdjustRefCountRatio,
65  "The ratio of the final CPU time ratio for adjusting the reference"
66  "count of RCP objects versus std::shared_ptr objects."
67  );
68 #endif
69  clp.setOption(
70  "max-rcp-raw-obj-access-ratio", &maxRcpRawObjAccessRatio,
71  "The ratio of the final CPU time ratio for accessing the object for RCP"
72  "versus a raw pointer."
73  );
74 
75 }
76 
77 
78 template<typename T>
79 struct DeleteDeleter {};
80 
81 
82 TEUCHOS_UNIT_TEST( RCP, _sizeofObjects )
83 {
84  out << "\nPrinting the size the RCP and RCPNodeImpl objects ...\n";
85  TEST_INEQUALITY_CONST(sizeof(bool), 0);
86  TEST_INEQUALITY_CONST(sizeof(double), 0);
87  TEST_INEQUALITY_CONST(sizeof(double*), 0);
88  TEST_INEQUALITY_CONST(sizeof(std::vector<double>), 0);
92  TEST_INEQUALITY_CONST(sizeof(Teuchos::RCP<std::vector<double> >), 0);
94  sizeof(Teuchos::RCPNodeTmpl<std::vector<double>,
95  Teuchos::DeallocDelete<std::vector<double> > >),
96  0);
97 }
98 
99 
100 TEUCHOS_UNIT_TEST( RCP, createDestroyOverhead )
101 {
102 
103  typedef Teuchos::TabularOutputter TO;
104 
105  const int maxLoopIters = 1000;
106  const double relTestCost = 1e-3;
107  const double numInnerLoops = relCpuSpeed / relTestCost;
108 
109  out << "\n"
110  << "Messuring the overhead of creating and destorying objects of different sizes\n"
111  << "using raw C++ pointers,"
112 #ifdef HAVE_TEUCHOSCORE_CXX11
113  << " shared_ptr,"
114 #endif
115  << " and using RCP.\n"
116  << "\n"
117  << "Number of loops = relCpuSpeed/relTestCost = "
118  << relCpuSpeed << "/" << relTestCost << " = " << numInnerLoops << "\n"
119  << "\n";
120 
121  TabularOutputter outputter(out);
122  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
123  outputter.setFieldTypePrecision(TO::INT, intPrec);
124 
125  outputter.pushFieldSpec("obj size", TO::INT);
126  outputter.pushFieldSpec("num loops", TO::INT);
127  outputter.pushFieldSpec("raw", TO::DOUBLE);
128 #ifdef HAVE_TEUCHOSCORE_CXX11
129  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
130 #endif
131  outputter.pushFieldSpec("RCP", TO::DOUBLE);
132 #ifdef HAVE_TEUCHOSCORE_CXX11
133  outputter.pushFieldSpec("shared_ptr/raw", TO::DOUBLE);
134 #endif
135  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
136 
137  outputter.outputHeader();
138 
139  double finalRcpRawRatio = 100000.0;
140 
141  int arraySize = 1;
142  for (int test_case_k = 0;
143  test_case_k < maxLoopIters && arraySize <= maxArraySize;
144  ++test_case_k
145  )
146  {
147 
148  // obj size
149  outputter.outputField(arraySize);
150 
151  // num loops
152  const int numActualLoops =
153  TEUCHOS_MAX(
154  static_cast<int>(
155  (numInnerLoops / arraySize)
156  * std::log(static_cast<double>(arraySize+1))
157  ),
158  1
159  );
160  outputter.outputField(numActualLoops);
161 
162  // raw
163  {
164  std::vector<std::vector<char>*> p_raw_vec(numActualLoops);
165  int i = 0;
166  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
167  {
168  p_raw_vec[i] = new std::vector<char>(arraySize, 1);
169  delete p_raw_vec[i];
170  ++i;
171  }
172  }
173  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
174 
175 #ifdef HAVE_TEUCHOSCORE_CXX11
176  // shared_ptr
177  {
178  typedef std::shared_ptr<std::vector<char> > shared_ptr_t;
179  std::vector<shared_ptr_t > sp_vec(numActualLoops);
180  int i = 0;
181  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
182  {
183  sp_vec[i] = shared_ptr_t(new std::vector<char>(arraySize, 1));
184  sp_vec[i].reset();
185  ++i;
186  }
187  }
188  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
189 #endif
190 
191  // RCP
192  {
193  std::vector<RCP<std::vector<char> > > p_vec(numActualLoops);
194  int i = 0;
195  TEUCHOS_START_PERF_OUTPUT_TIMER(outputter, numActualLoops)
196  {
197  p_vec[i] = rcp(new std::vector<char>(arraySize, 1));
198  p_vec[i] = null;
199  }
200  }
201  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
202 
203 #ifdef HAVE_TEUCHOSCORE_CXX11
204  // shared_ptr/rawPtr
205  const double spRatio = spTime / rawPtrTime;
206  outputter.outputField(spRatio);
207 #endif
208 
209  // RCP/rawPtr
210  const double rcpRatio = rcpTime / rawPtrTime;
211  outputter.outputField(rcpRatio);
212 
213  outputter.nextRow();
214 
215  arraySize *= 4;
216  finalRcpRawRatio = TEUCHOS_MIN(rcpRatio, finalRcpRawRatio);
217 
218  }
219 
220  out << "\n";
221  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawCreateDestroyRatio );
222  out << "\n";
223 
224 }
225 
226 
227 TEUCHOS_UNIT_TEST( RCP, referenceCountManipulationOverhead )
228 {
229 
230  typedef Teuchos::TabularOutputter TO;
231 
232  const double relTestCost = 5e-3;
233  const int maxLoopIters = 1000;
234  const double numInnerLoops = relCpuSpeed / relTestCost;
235 
236  out << "\n"
237  << "Messuring the overhead of incrementing and deincrementing the reference count\n"
238  << "comparing RCP to raw pointer"
239 #ifdef HAVE_TEUCHOSCORE_CXX11
240  << " and std::shared_ptr"
241 #endif
242  << ".\n"
243  << "\n";
244 
245  TabularOutputter outputter(out);
246  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
247  outputter.setFieldTypePrecision(TO::INT, intPrec);
248 
249  outputter.pushFieldSpec("array dim", TO::INT);
250  outputter.pushFieldSpec("num loops", TO::INT);
251  outputter.pushFieldSpec("raw", TO::DOUBLE);
252 #ifdef HAVE_TEUCHOSCORE_CXX11
253  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
254 #endif
255  outputter.pushFieldSpec("RCP", TO::DOUBLE);
256  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
257 #ifdef HAVE_TEUCHOSCORE_CXX11
258  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
259 #endif
260 
261  outputter.outputHeader();
262 
263  double finalRcpRawRatio = 100000.0;
264 #ifdef HAVE_TEUCHOSCORE_CXX11
265  double finalRcpSpRatio = 100000.0;
266 #endif
267  int arraySize = 64;
268 
269  for (
270  int test_case_k = 0;
271  test_case_k < maxLoopIters && arraySize <= maxArraySize;
272  ++test_case_k
273  )
274  {
275 
276  // array dim
277  outputter.outputField(arraySize);
278 
279  // num loops
280  const int numActualLoops =
281  TEUCHOS_MAX(
282  static_cast<int>(
283  (numInnerLoops / arraySize)
284  * std::log(static_cast<double>(arraySize+1))
285  ),
286  1
287  );
288  outputter.outputField(numActualLoops);
289 
290  // Note on std::shared_ptr and modification to the test
291  // Originally this test copied a single ptr
292  // Added 1 and 2 types ('n' and 'o') so that each copy would be unique
293  // std::shared_ptr for gcc (but not clang) will handle the case of setting
294  // a = b with b already equal to a in an optimized way and the original
295  // test format spent most of it's time in this case.
296 
297  // raw
298  {
299  char dummy_char1 = 'n';
300  char dummy_char2 = 'o'; // See above note for std::shared_ptr
301  std::vector<char*> p_raw_vec(arraySize);
302  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
303  {
304  for (int i=0; i < arraySize; ++i) {
305  p_raw_vec[i] = &dummy_char1;
306  p_raw_vec[i] = &dummy_char2; // See above note for std::shared_ptr
307  }
308  }
309  }
310  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
311 
312 #ifdef HAVE_TEUCHOSCORE_CXX11
313  // shared_ptr
314  {
315  typedef std::shared_ptr<char> shared_ptr_t;
316  shared_ptr_t sp1(new char('n'));
317  shared_ptr_t sp2(new char('o')); // See above note for std::shared_ptr
318  std::vector<shared_ptr_t> sp_vec(arraySize);
319  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
320  {
321  for (int i=0; i < arraySize; ++i) {
322  sp_vec[i] = sp1;
323  sp_vec[i] = sp2; // See above note for std::shared_ptr
324  }
325  }
326  }
327  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
328 #endif
329 
330  // RCP
331  {
332  RCP<char> p1(new char('n'));
333  RCP<char> p2(new char('o')); // See above note for std::shared_ptr
334  std::vector<RCP<char> > p_vec(arraySize);
335  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
336  {
337  for (int i=0; i < arraySize; ++i) {
338  p_vec[i] = p1;
339  p_vec[i] = p2; // See above note for std::shared_ptr
340  // NOTE: This assignment operation tests the copy constructor and
341  // the swap function. This calls both bind() and unbind()
342  // underneath.
343  }
344  }
345  }
346  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
347 
348  // RCP/raw
349  const double rcpRawRatio = rcpTime / rawPtrTime;
350  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
351  outputter.outputField(rcpRawRatio);
352 
353 #ifdef HAVE_TEUCHOSCORE_CXX11
354  // RCP/shared_ptr
355  const double rcpSpRatio = rcpTime / spTime;
356  finalRcpSpRatio = TEUCHOS_MIN(rcpSpRatio, finalRcpSpRatio);
357  outputter.outputField(rcpSpRatio);
358 #endif
359 
360  outputter.nextRow();
361 
362  arraySize *= 4;
363 
364  }
365 
366  out << "\n";
367  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawAdjustRefCountRatio );
368  out << "\n";
369 #ifdef HAVE_TEUCHOSCORE_CXX11
370  TEST_COMPARE( finalRcpSpRatio, <=, maxRcpSpAdjustRefCountRatio );
371  out << "\n";
372 #endif
373 
374 }
375 
376 
377 TEUCHOS_UNIT_TEST( RCP, dereferenceOverhead )
378 {
379 
380  typedef Teuchos::TabularOutputter TO;
381 
382  const double relTestCost = 1e-4;
383  const int maxLoopIters = 1000;
384  const double numInnerLoops = relCpuSpeed / relTestCost;
385 
386  out << "\n"
387  << "Measuring the overhead of dereferencing RCP"
388 #ifdef HAVE_TEUCHOSCORE_CXX11
389  << ", shared_ptr"
390 #endif
391  << " and a raw pointer.\n"
392  << "\n";
393 
394  TabularOutputter outputter(out);
395  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
396  outputter.setFieldTypePrecision(TO::INT, intPrec);
397 
398  outputter.pushFieldSpec("array dim", TO::INT);
399  outputter.pushFieldSpec("num loops", TO::INT);
400  outputter.pushFieldSpec("raw", TO::DOUBLE);
401 #ifdef HAVE_TEUCHOSCORE_CXX11
402  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
403 #endif
404  outputter.pushFieldSpec("RCP", TO::DOUBLE);
405  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
406 #ifdef HAVE_TEUCHOSCORE_CXX11
407  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
408 #endif
409 
410  outputter.outputHeader();
411 
412  double finalRcpRawRatio = 100000.0;
413  int arraySize = 64;
414  const int dummy_int_val = 1;
415  int overall_dummy_int_out = 0;
416 
417 
418  for (
419  int test_case_k = 0;
420  test_case_k < maxLoopIters && arraySize <= maxArraySize;
421  ++test_case_k
422  )
423  {
424 
425  // array dim
426  outputter.outputField(arraySize);
427 
428  // num loops
429  const int numActualLoops =
430  TEUCHOS_MAX(
431  static_cast<int>(
432  (numInnerLoops / arraySize)
433  * std::log(static_cast<double>(arraySize+1))
434  ),
435  1
436  );
437  outputter.outputField(numActualLoops);
438 
439  int dummy_int_out = 0;
440 
441  // raw
442  {
443  int dummy_int = dummy_int_val;
444  std::vector<int*> p_raw_vec(arraySize);
445  for (int i=0; i < arraySize; ++i) {
446  p_raw_vec[i] = &dummy_int;
447  }
448  dummy_int_out = 0;
449  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
450  {
451  for (int i=0; i < arraySize; ++i) {
452  dummy_int_out += *p_raw_vec[i];
453  }
454  }
455  }
456  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
457  overall_dummy_int_out += dummy_int_out;
458 
459 #ifdef HAVE_TEUCHOSCORE_CXX11
460  // shared_ptr
461  {
462  typedef std::shared_ptr<int> shared_ptr_t;
463  shared_ptr_t sp(new int(dummy_int_val));
464  std::vector<shared_ptr_t> sp_vec(arraySize);
465  for (int i=0; i < arraySize; ++i) {
466  sp_vec[i] = sp;
467  }
468  dummy_int_out = 0;
469  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
470  {
471  for (int i=0; i < arraySize; ++i) {
472  dummy_int_out += *sp_vec[i];
473  }
474  }
475  }
476  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
477  overall_dummy_int_out += dummy_int_out;
478 #endif
479 
480  // RCP
481  {
482  RCP<int> p(new int(dummy_int_val));
483  std::vector<RCP<int> > p_vec(arraySize);
484  for (int i=0; i < arraySize; ++i) {
485  p_vec[i] = p;
486  }
487  dummy_int_out = 0;
488  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
489  {
490  for (int i=0; i < arraySize; ++i) {
491  dummy_int_out += *p_vec[i];
492  }
493  }
494  }
495  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
496  overall_dummy_int_out += dummy_int_out;
497 
498  // RCP/raw
499  const double rcpRawRatio = rcpTime / rawPtrTime;
500  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
501  outputter.outputField(rcpRawRatio);
502 
503 #ifdef HAVE_TEUCHOSCORE_CXX11
504  // RCP/shared_ptr
505  const double rcpSpRatio = rcpTime / spTime;
506  outputter.outputField(rcpSpRatio);
507 #endif
508 
509  outputter.nextRow();
510 
511  arraySize *= 4;
512 
513  }
514 
515  out << "\n";
516  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawObjAccessRatio );
517  out << "\n";
518 
519  // This silly variable must be accumulated or compilers like MSVC++ will
520  // optimize away the loops!
521  if (overall_dummy_int_out == 0)
522  success = false;
523 
524 }
525 
526 
527 struct SomeStruct {
528  SomeStruct(int member_in) : member(member_in) {}
529  int member;
530 };
531 
532 
533 TEUCHOS_UNIT_TEST( RCP, memberAccessOverhead )
534 {
535 
536  typedef Teuchos::TabularOutputter TO;
537 
538  const double relTestCost = 1e-4;
539  const int maxLoopIters = 1000;
540  const double numInnerLoops = relCpuSpeed / relTestCost;
541 
542  out << "\n"
543  << "Measuring the overhead of dereferencing RCP"
544 #ifdef HAVE_TEUCHOSCORE_CXX11
545  << ", shared_ptr"
546 #endif
547  << " and a raw pointer.\n"
548  << "\n";
549 
550  TabularOutputter outputter(out);
551  outputter.setFieldTypePrecision(TO::DOUBLE, dblPrec);
552  outputter.setFieldTypePrecision(TO::INT, intPrec);
553 
554  outputter.pushFieldSpec("array dim", TO::INT);
555  outputter.pushFieldSpec("num loops", TO::INT);
556  outputter.pushFieldSpec("raw", TO::DOUBLE);
557 #ifdef HAVE_TEUCHOSCORE_CXX11
558  outputter.pushFieldSpec("shared_ptr", TO::DOUBLE);
559 #endif
560  outputter.pushFieldSpec("RCP", TO::DOUBLE);
561  outputter.pushFieldSpec("RCP/raw", TO::DOUBLE);
562 #ifdef HAVE_TEUCHOSCORE_CXX11
563  outputter.pushFieldSpec("RCP/shared_ptr", TO::DOUBLE);
564 #endif
565 
566  outputter.outputHeader();
567 
568  double finalRcpRawRatio = 100000.0;
569  int arraySize = 64;
570  const int dummy_int_val = 1;
571  int overall_dummy_int_out = 0;
572 
573  for (
574  int test_case_k = 0;
575  test_case_k < maxLoopIters && arraySize <= maxArraySize;
576  ++test_case_k
577  )
578  {
579 
580  // array dim
581  outputter.outputField(arraySize);
582 
583  // num loops
584  const int numActualLoops =
585  TEUCHOS_MAX(
586  static_cast<int>(
587  (numInnerLoops / arraySize)
588  * std::log(static_cast<double>(arraySize+1))
589  ),
590  1
591  );
592  outputter.outputField(numActualLoops);
593 
594  int dummy_int_out = 0;
595 
596  // raw
597  {
598  SomeStruct dummy_SomeStruct(dummy_int_val);
599  std::vector<SomeStruct*> p_raw_vec(arraySize);
600  for (int i=0; i < arraySize; ++i) {
601  p_raw_vec[i] = &dummy_SomeStruct;
602  }
603  dummy_int_out = 0;
604  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
605  {
606  for (int i=0; i < arraySize; ++i) {
607  dummy_int_out += p_raw_vec[i]->member;
608  }
609  }
610  }
611  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rawPtrTime);
612  overall_dummy_int_out += dummy_int_out;
613 
614 #ifdef HAVE_TEUCHOSCORE_CXX11
615  // shared_ptr
616  {
617  typedef std::shared_ptr<SomeStruct> shared_ptr_t;
618  shared_ptr_t sp(new SomeStruct(dummy_int_val));
619  std::vector<shared_ptr_t> sp_vec(arraySize);
620  for (int i=0; i < arraySize; ++i) {
621  sp_vec[i] = sp;
622  }
623  dummy_int_out = 0;
624  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
625  {
626  for (int i=0; i < arraySize; ++i) {
627  dummy_int_out += sp_vec[i]->member;
628  }
629  }
630  }
631  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, spTime);
632  overall_dummy_int_out += dummy_int_out;
633 #endif
634 
635  // RCP
636  {
637  RCP<SomeStruct> p(new SomeStruct(dummy_int_val));
638  std::vector<RCP<SomeStruct> > p_vec(arraySize);
639  for (int i=0; i < arraySize; ++i) {
640  p_vec[i] = p;
641  }
642  dummy_int_out = 0;
643  TEUCHOS_START_PERF_OUTPUT_TIMER_INNERLOOP(outputter, numActualLoops, arraySize)
644  {
645  for (int i=0; i < arraySize; ++i) {
646  dummy_int_out += p_vec[i]->member;
647  }
648  }
649  }
650  TEUCHOS_END_PERF_OUTPUT_TIMER(outputter, rcpTime);
651  overall_dummy_int_out += dummy_int_out;
652 
653  // RCP/raw
654  const double rcpRawRatio = rcpTime / rawPtrTime;
655  finalRcpRawRatio = TEUCHOS_MIN(rcpRawRatio, finalRcpRawRatio);
656  outputter.outputField(rcpRawRatio);
657 
658 #ifdef HAVE_TEUCHOSCORE_CXX11
659  // RCP/shared_ptr
660  const double rcpSpRatio = rcpTime / spTime;
661  outputter.outputField(rcpSpRatio);
662 #endif
663 
664  outputter.nextRow();
665 
666  arraySize *= 4;
667 
668  }
669 
670  out << "\n";
671  TEST_COMPARE( finalRcpRawRatio, <=, maxRcpRawObjAccessRatio );
672  out << "\n";
673 
674  // This silly variable must be accumulated or compilers like MSVC++ will
675  // optimize away the loops!
676  if (overall_dummy_int_out == 0)
677  success = false;
678 
679 }
680 
681 
682 
683 
684 
685 
686 
687 } // 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;&gt;=&quot;, &quot;!=", 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()