code_junkie

C++ Smart Pointer performance

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <tr1/memory>
  3.  
  4. int main()
  5. {
  6. #ifdef USE_SHARED_PTR
  7. std::tr1::shared_ptr<volatile int> i(new int(1));
  8. #else
  9. volatile int * i = new int(1);
  10. #endif
  11.  
  12. long long int h = 0;
  13.  
  14. for(long long int j=0;j < 10000000000LL; j++)
  15. {
  16. h += *i;
  17. }
  18.  
  19. std::cout << h << std::endl;
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment