// Copyright 2015, Tobias Hermann and the FunctionalPlus contributors. // https://github.com/Dobiasd/FunctionalPlus // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #pragma once #include namespace fplus { class stopwatch { public: stopwatch() : beg_(clock::now()) {} void reset() { beg_ = clock::now(); } // time since creation or last reset in seconds double elapsed() const { return std::chrono::duration_cast (clock::now() - beg_).count(); } private: typedef std::chrono::high_resolution_clock clock; typedef std::chrono::duration> second; std::chrono::time_point beg_; }; } // namespace fplus