loop: metrics
This commit is contained in:
parent
f86c810aea
commit
426988b000
@ -87,6 +87,12 @@ UVW_INLINE loop::time loop::idle_time() const noexcept {
|
|||||||
return time{uv_metrics_idle_time(uv_loop.get())};
|
return time{uv_metrics_idle_time(uv_loop.get())};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UVW_INLINE metrics_type loop::metrics() const noexcept {
|
||||||
|
metrics_type res{};
|
||||||
|
uv_metrics_info(uv_loop.get(), &res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
UVW_INLINE loop::time loop::now() const noexcept {
|
UVW_INLINE loop::time loop::now() const noexcept {
|
||||||
return time{uv_now(uv_loop.get())};
|
return time{uv_now(uv_loop.get())};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,8 @@ enum class uvw_run_mode : std::underlying_type_t<uv_run_mode> {
|
|||||||
|
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
|
using metrics_type = uv_metrics_t; /*!< Library equivalent for uv_metrics_t. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The loop class.
|
* @brief The loop class.
|
||||||
*
|
*
|
||||||
@ -236,6 +238,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
time idle_time() const noexcept;
|
time idle_time() const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Tracks various internal operations of the event loop.
|
||||||
|
* @return Event loop metrics.
|
||||||
|
*/
|
||||||
|
metrics_type metrics() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current timestamp in milliseconds.
|
* @brief Returns the current timestamp in milliseconds.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -124,6 +124,14 @@ TEST(Loop, IdleTime) {
|
|||||||
ASSERT_EQ(0, loop->close());
|
ASSERT_EQ(0, loop->close());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Loop, Metrics) {
|
||||||
|
auto loop = uvw::loop::create();
|
||||||
|
uvw::metrics_type metrics = loop->metrics();
|
||||||
|
ASSERT_EQ(0, metrics.loop_count);
|
||||||
|
ASSERT_EQ(0, metrics.events);
|
||||||
|
ASSERT_EQ(0, metrics.events_waiting);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Loop, Raw) {
|
TEST(Loop, Raw) {
|
||||||
auto loop = uvw::loop::get_default();
|
auto loop = uvw::loop::get_default();
|
||||||
const auto &cloop = uvw::loop::get_default();
|
const auto &cloop = uvw::loop::get_default();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user