diff options
Diffstat (limited to 'nemesis')
| -rw-r--r-- | nemesis/causal_event_loop.py | 20 | ||||
| -rw-r--r-- | nemesis/html_gen.py | 22 |
2 files changed, 29 insertions, 13 deletions
diff --git a/nemesis/causal_event_loop.py b/nemesis/causal_event_loop.py index c2b3b1d..f4834fc 100644 --- a/nemesis/causal_event_loop.py +++ b/nemesis/causal_event_loop.py @@ -93,7 +93,7 @@ class CausalEventLoop(asyncio.SelectorEventLoop): # 1 means the target coroutine is optimized away entirely _speedup = 1.0 # a list of callbacks which have recently completed - _pause_buffer = SortedList() + _pause_buffer = [] # a list of intervals in which the target coroutine has been active _coro_intervals = SortedList() # a list of completed callbacks, and their associated queue time @@ -202,9 +202,13 @@ class CausalEventLoop(asyncio.SelectorEventLoop): time_to_buffer = when + self._get_pause_for_io(handle, curr_time) handle._when = time_to_buffer handle.time_entered_pause_buffer = curr_time - self._pause_buffer.add(handle) + heapq.heappush(self._pause_buffer, handle) # handle callbacks which can leave pause timeout + # if len(self._pause_buffer) > 100: + # exit(1) + heapq.heapify(self._pause_buffer) + # print([x._when for x in self._pause_buffer]) while self._pause_buffer: handle = self._pause_buffer[0] if handle._when >= end_time: @@ -219,7 +223,7 @@ class CausalEventLoop(asyncio.SelectorEventLoop): self._get_pause_for_pause_time(handle, curr_time) if handle._when >= end_time: handle.time_entered_pause_buffer = curr_time - self._pause_buffer.add(handle) + heapq.heappush(self._pause_buffer, handle) else: self._ready.append(handle) @@ -310,12 +314,12 @@ class CausalEventLoop(asyncio.SelectorEventLoop): def _add_callback(self, handle): """Add a Handle to _pause_buffer.""" - if not handle._cancelled: - curr_time = self.time() - if not handle._when: - handle._when = curr_time + curr_time = self.time() + if not handle._when: + handle._when = curr_time + if not handle._cancelled and handle not in self._pause_buffer: handle.time_entered_pause_buffer = curr_time - self._pause_buffer.add(handle) + heapq.heappush(self._pause_buffer, handle) def _get_pause_for_io(self, handle, io_time): time_interval = (handle.register_time, io_time) diff --git a/nemesis/html_gen.py b/nemesis/html_gen.py index b774da9..841fbbc 100644 --- a/nemesis/html_gen.py +++ b/nemesis/html_gen.py @@ -8,13 +8,14 @@ def get_color(name): return f'hsl({color_index}, 100%, 50%)' def plot_results(results, filename): - fig = make_subplots(rows=3, cols=1) + fig = make_subplots(rows=4, cols=1) for i, (coro_name, x_values) in enumerate(results.items(), start=1): x_list = [] y_latency_list = [] y_throughput_list = [] y_max_latency_list = [] + y_num_callbacks_list = [] for speedup, experiments in x_values.items(): for experiment in experiments: @@ -25,6 +26,7 @@ def plot_results(results, filename): x_list.append(speedup * 100) num_callbacks = len(completed_callbacks) + y_num_callbacks_list.append(num_callbacks) # handle average latency graph if num_callbacks > 0: @@ -69,9 +71,19 @@ def plot_results(results, filename): showlegend=False, ), row=3, col=1) - fig.update_xaxes(title_text="Speedup (% optimized away)", row=3, col=1) - fig.update_yaxes(title_text="Average Handle Latency (seconds)", row=1, col=1) - fig.update_yaxes(title_text="Throughput (callbacks per second)", row=2, col=1) - fig.update_yaxes(title_text="Maximum Handle Latency (seconds)", row=3, col=1) + fig.add_trace(go.Scatter( + x=x_list, + y=y_num_callbacks_list, + mode='markers', + name=coro_name, + marker=dict(color=get_color(coro_name)), + showlegend=False, + ), row=4, col=1) + + fig.update_xaxes(title_text="speedup (% optimized away)", row=4, col=1) + fig.update_yaxes(title_text="average latency (seconds)", row=1, col=1) + fig.update_yaxes(title_text="throughput (handles per second)", row=2, col=1) + fig.update_yaxes(title_text="maximum latency (seconds)", row=3, col=1) + fig.update_yaxes(title_text="# of callbacks", row=4, col=1) fig.write_html(filename) |
