fork download
  1. #include <chrono>
  2. #include <iostream>
  3.  
  4. class Stopwatch {
  5. public:
  6. typedef std::chrono::high_resolution_clock Clock;
  7. Clock::time_point start;
  8. Stopwatch(): start(Clock::now()) {}
  9. void elapsed() {
  10. std::cout << "Elapsed time: " << std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now()-start).count() << " ms\n";
  11. }
  12. };
  13.  
  14. int main() {
  15. Stopwatch k;
  16. k.elapsed();
  17. }
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
Elapsed time: 0 ms