Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. DWORD start = ::GetTickCount(); // start counter
  2.  
  3. // all the things your program does
  4.  
  5. DWORD end = ::GetTickCount(); // stop counter
  6. DWORD duration = end - start;
  7. std::cout << "Duration: " << duration << " ms" << std::endl;
  8.  
  9. #include <QDebug>
  10. #include <QElapsedTimer>
  11. #define CONCAT_(x,y) x##y
  12. #define CONCAT(x,y) CONCAT_(x,y)
  13.  
  14. #define CHECKTIME(x)
  15. QElapsedTimer CONCAT(sb_, __LINE__);
  16. CONCAT(sb_, __LINE__).start();
  17. x
  18. qDebug() << __FUNCTION__ << ":" << __LINE__ << " Elapsed time: " << CONCAT(sb_, __LINE__).elapsed() << " ms.";
  19.  
  20. CHECKTIME(
  21. // any code
  22. for (int i=0; i<1000; i++)
  23. {
  24. timeConsumingFunc();
  25. }
  26. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement