Search notes:

C++ Standard Library: chrono::high_resolution_clock now()

//
// g++ -std=c++11 high_resolution_clock-now.cpp
//
#include <chrono>
#include <iostream>
#include <thread>

int main() {


  auto t0 = std::chrono::high_resolution_clock::now();

  std::cout << "Filling time between t0 and t1" << std::endl;

  std::this_thread::sleep_for(std::chrono::milliseconds(17));

  auto t1 = std::chrono::high_resolution_clock::now();

  std::chrono::duration<float> t_diff = t1 - t0;

  std::chrono::milliseconds t_diff_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t_diff);

  std::cout << "t_diff_ms = " << t_diff_ms.count() << std::endl;

}
Github repository about-cpp-standard-library, path: /chrono/high_resolution_clock-now.cpp
Output:
Filling time between t0 and t1
t_diff_ms = 17

See also

C++ Standard Library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390569, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/CPP-Standard-Library/chrono/high_resolution_clock-now(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78