xtd 0.2.0
Loading...
Searching...
No Matches
stopwatch_constructor.cpp

Initializes a xtd::diagnostics::stopwatch instance by using a simple class constructor.

#include <xtd/diagnostics/stopwatch>
#include <xtd/threading/thread>
#include <xtd/console>
#include <chrono>
using namespace std::chrono;
using namespace xtd;
using namespace xtd::threading;
auto main() -> int {
auto stopwatch = xtd::diagnostics::stopwatch {};
stopwatch.start();
thread::sleep(10000_ms);
stopwatch.stop();
// Get the elapsed time as a duration value.
auto ts = stopwatch.elapsed();
// Format and display the duration value.
auto elapsed_time = string::format("{0:H}:{0:M}:{0:S}.{1:D2}", ts, ts.milliseconds() / 10);
console::write_line("RunTime " + elapsed_time);
}
// This code produces the following output :
//
// RunTime 00:00:10.00
Provides a set of methods and properties that you can use to accurately measure elapsed time.
Definition stopwatch.h:36
void start() noexcept
Starts, or resumes, measuring elapsed time for an interval.
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10