Commit c483fe4f authored by Juho Snellman's avatar Juho Snellman

Make benchmark more deterministic

- Depending on the exact execution order of timers with same
  expiration time, the exact results would depend on whether the
  "close" timer was the first or second of those two.
- Do a two phase close; first time around just go to a draining
  mode. Then after all activity has been drained, delete the
  object properly.
- Also gives us a more diverse event mix, since it currently
  might not have quite enough medium length timers that actually
  get executed.
parent cbe1c82a
......@@ -66,7 +66,17 @@ public:
}
void on_close() {
if (closing_) {
delete this;
} else {
// First time the timeout triggers, we just put the
// object into a closing state where it'll start winding down
// work. Then we forcibly close it a bit later. We do it like
// this to remove any non-determinism between the execution order
// of the close timer and the pace timer.
closing_ = true;
timers_->schedule(&close_timer_, 10*1000*50);
}
}
void on_pace() {
if (tx_count_) {
......@@ -78,8 +88,10 @@ public:
delete this;
}
void on_request() {
if (!closing_) {
other_->transmit(100);
}
}
void unidle() {
if (allow_schedule_in_range) {
......@@ -106,6 +118,7 @@ private:
int pace_quota_ = 1;
int pace_interval_ticks_ = 10;
int request_interval_ = 100;
bool closing_ = false;
};
int Unit::id_counter_ = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment