SHARE
TWEET

Untitled

a guest Aug 9th, 2019 4 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <chrono>
  2. #include <iostream>
  3.  
  4. int main()
  5. {  
  6.     {    
  7.         const auto Start = std::chrono::system_clock::now();
  8.         for (int i = 0; i < 1'000'000; ++i)
  9.         {
  10.             std::cout << "Hello World\n";
  11.         }
  12.         const auto End = std::chrono::system_clock::now();
  13.         const std::chrono::duration<double> Duration = End - Start;
  14.         std::cout << "std::cout Time: " << std::chrono::duration_cast<std::chrono::microseconds>(Duration).count() << " us\n";
  15.     }
  16.  
  17.     {  
  18.         const auto Start = std::chrono::system_clock::now();
  19.         for (int i = 0; i < 1'000'000; ++i)
  20.         {
  21.             printf("Hello World\n");
  22.         }
  23.         const auto End = std::chrono::system_clock::now();
  24.         const std::chrono::duration<double> Duration = End - Start;
  25.         std::cout << "printf Time: " << std::chrono::duration_cast<std::chrono::microseconds>(Duration).count() << " us\n";
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top