-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #15: Implement ZeroMQ-based latency histogram recorder.
* It records latency histogram automagically. * TODO: auto-detect peer pktgen address. (currently hard-coded..) * TODO: auto-calculate CDF for easier plotting
- Loading branch information
Showing
3 changed files
with
67 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
import aiozmq, zmq | ||
|
||
class LatencyHistogramReader: | ||
|
||
def __init__(self, loop=None): | ||
self._loop = loop if loop else asyncio.get_event_loop() | ||
self.records = [] | ||
|
||
async def subscribe(self, remote_host, remote_cpu_idx): | ||
self.remote_addr = 'tcp://{}:{}'.format(remote_host, remote_cpu_idx) | ||
self._conn = await aiozmq.create_zmq_stream(zmq.SUB, loop=self._loop, | ||
connect=self.remote_addr) | ||
self._conn.transport.setsockopt(zmq.SUBSCRIBE, b'') | ||
while True: | ||
try: | ||
recv_data = await self._conn.read() | ||
except asyncio.CancelledError: | ||
self._conn.close() | ||
break | ||
cpu_idx = int(recv_data[0].decode()) | ||
elapsed_sec = int(recv_data[1].decode()) | ||
# TODO: convert to sparse DataFrame | ||
histogram = recv_data[2].decode().splitlines() | ||
self.records.append((cpu_idx, elapsed_sec, histogram)) | ||
|
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