fork download
  1. #include <iostream>
  2. #include <chrono>
  3. #include <thread>
  4. typedef std::chrono::high_resolution_clock Clock;
  5.  
  6. std::string toString() {
  7. return "String_" + std::to_string(rand() % 100);
  8. }
  9.  
  10. bool Verbose;
  11. void log(const std::string& S) {
  12. if (Verbose)
  13. return;
  14. }
  15.  
  16. int main()
  17. {
  18. Verbose = false;
  19. std::chrono::milliseconds three_milliseconds{3};
  20.  
  21. void *P;
  22. auto t1 = Clock::now();
  23. for (int I = 0; I < 1000000; ++I)
  24. log(toString());
  25. auto t2 = Clock::now();
  26.  
  27. std::cout << "Delta t2-t1: "
  28. << std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count()
  29. << " milliseconds" << std::endl;
  30. std::cout << P;
  31. }
Success #stdin #stdout 0.08s 15240KB
stdin
Standard input is empty
stdout
Delta t2-t1: 80 milliseconds
0