-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how ReactionStatistics works to be more useful for monitoring …
…events (#125) Changes ReactionStatistics so it no longer only fires at the very end of a reaction. It will now fire progress updates as it goes through to allow monitoring of how reactions are going. It also better conforms to trace file semantics so that they can be used to track reactions Superceeds #99 as it integrates those changes too
- Loading branch information
1 parent
0767eab
commit 03d3138
Showing
9 changed files
with
383 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "usage_clock.hpp" | ||
|
||
#include <chrono> | ||
|
||
// Windows | ||
#if defined(_WIN32) | ||
#include "platform.hpp" | ||
|
||
namespace NUClear { | ||
namespace util { | ||
|
||
cpu_clock::time_point cpu_clock::now() noexcept { | ||
FILETIME creation_time; | ||
FILETIME exit_time; | ||
FILETIME kernel_time; | ||
FILETIME user_time; | ||
if (GetThreadTimes(GetCurrentThread(), &creation_time, &exit_time, &kernel_time, &user_time) != -1) { | ||
// Time in in 100 nanosecond intervals | ||
uint64_t time = ((uint64_t(user_time.dwHighDateTime) << 32) | user_time.dwLowDateTime) | ||
+ ((uint64_t(kernel_time.dwHighDateTime) << 32) | kernel_time.dwLowDateTime); | ||
return time_point(std::chrono::duration<uint64_t, std::ratio<1LL, 10000000LL>>(time)); | ||
} | ||
return time_point(); | ||
} | ||
|
||
} // namespace util | ||
} // namespace NUClear | ||
|
||
#else | ||
#include <ctime> | ||
|
||
namespace NUClear { | ||
namespace util { | ||
|
||
cpu_clock::time_point cpu_clock::now() noexcept { | ||
::timespec ts{}; | ||
::clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); | ||
return time_point(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)); | ||
} | ||
|
||
} // namespace util | ||
} // namespace NUClear | ||
|
||
#endif // _WIN32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef NUCLEAR_UTIL_USAGE_CLOCK_HPP | ||
#define NUCLEAR_UTIL_USAGE_CLOCK_HPP | ||
|
||
#include <chrono> | ||
|
||
namespace NUClear { | ||
namespace util { | ||
|
||
/** | ||
* A clock that measures CPU time. | ||
*/ | ||
struct cpu_clock { | ||
using duration = std::chrono::nanoseconds; ///< The duration type of the clock. | ||
using rep = duration::rep; ///< The representation type of the duration. | ||
using period = duration::period; ///< The tick period of the clock. | ||
using time_point = std::chrono::time_point<cpu_clock>; ///< The time point type of the clock. | ||
static const bool is_steady = true; ///< Indicates if the clock is steady. | ||
|
||
/** | ||
* Get the current time point of the cpu clock for the current thread | ||
* | ||
* @return The current time point. | ||
*/ | ||
static time_point now() noexcept; | ||
}; | ||
|
||
} // namespace util | ||
} // namespace NUClear | ||
|
||
#endif // NUCLEAR_UTIL_USAGE_CLOCK_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.