def test_add_throughput_event_total_bytes(self):
     self.assertEqual(0, throughput_statistics.interval_data.total_in)
     throughput_statistics.add_event(NetworkDirection.INBOUND, "mock_msg",
                                     100, "localhost 0000")
     throughput_statistics.add_event(NetworkDirection.INBOUND, "mock_msg",
                                     100, "localhost 0000")
     self.assertEqual(200, throughput_statistics.interval_data.total_in)
 def test_add_throughput_event_peer_count(self):
     self.assertEqual(
         0, len(throughput_statistics.interval_data.peer_to_stats))
     throughput_statistics.add_event(NetworkDirection.INBOUND, "mock_msg",
                                     100, "localhost 0000")
     self.assertEqual(
         1, len(throughput_statistics.interval_data.peer_to_stats))
Example #3
0
 def test_add_throughput_event_flush(self):
     self.assertEqual(1, throughput_statistics.reset)
     self.assertEqual(0, throughput_statistics.interval_data.total_in)
     throughput_statistics.add_event(Direction.INBOUND, "mock_msg", 100, "localhost 0000")
     self.assertEqual(100, throughput_statistics.interval_data.total_in)
     throughput_statistics.flush_info()
     self.assertEqual(0, throughput_statistics.interval_data.total_in)
Example #4
0
def add_throughput_event(
    direction: NetworkDirection,
    msg_type: str,
    msg_size: int,
    peer_desc: str,
    peer_id: Optional[str] = None,
):
    return throughput_statistics.add_event(direction, msg_type, msg_size,
                                           peer_desc, peer_id)
Example #5
0
def add_throughput_event(direction, msg_type, msg_size, peer_desc):
    return throughput_statistics.add_event(direction, msg_type, msg_size,
                                           peer_desc)