xo-alloc: track GC efficiency
This commit is contained in:
parent
d751093a87
commit
0a19c8b043
2 changed files with 28 additions and 0 deletions
|
|
@ -176,6 +176,17 @@ namespace xo {
|
|||
dt_{dt} {}
|
||||
constexpr GcStatisticsHistoryItem(const GcStatisticsHistoryItem &) = default;
|
||||
|
||||
std::size_t garbage_z() const { return garbage0_z_ + garbage1_z_ + garbageN_z_; }
|
||||
|
||||
float efficiency() const {
|
||||
std::size_t gz = this->garbage_z();
|
||||
|
||||
return gz / static_cast<float>(effort_z_ + gz);
|
||||
}
|
||||
|
||||
/** collection rate, in bytes/sec **/
|
||||
float collection_rate() const;
|
||||
|
||||
GcStatisticsHistoryItem & operator=(const GcStatisticsHistoryItem & x) {
|
||||
gc_seq_ = x.gc_seq_;
|
||||
upto_ = x.upto_;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,23 @@ namespace xo {
|
|||
<< ">";
|
||||
}
|
||||
|
||||
float
|
||||
GcStatisticsHistoryItem::collection_rate() const {
|
||||
using namespace xo::qty::qty;
|
||||
|
||||
float gz = this->garbage_z();
|
||||
|
||||
auto dt_nanos = this->dt_.with_repr<float>();
|
||||
auto dt_sec = dt_nanos.rescale_ext<xo::qty::u::second>();
|
||||
auto rate = gz / dt_sec;
|
||||
float retval = rate.scale();
|
||||
|
||||
//scope log(XO_DEBUG(true));
|
||||
//log && log(xtag("gz", gz), xtag("dt_sec", dt_sec), xtag("rate", rate), xtag("rate/sec", retval));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
GcStatisticsHistoryItem::display(std::ostream & os) const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue