traffic: optimize packet init for better performance
authorJoe Guo <joeg@catalyst.net.nz>
Thu, 10 May 2018 02:53:55 +0000 (14:53 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 14 May 2018 00:53:16 +0000 (02:53 +0200)
commit21c82072ab87e3dee617b3219364e55e9c106432
tree72a37e90d7481ec9b507a7db02c12c834ea083f4
parent2fc6cbb8cb4931f7f4b130817859d2a283ac541c
traffic: optimize packet init for better performance

When we run traffic_replay, we are creating millions of Packet objects.
So small change in Packet.__init__ will make big difference.

By initializing packet with converted values without parsing string, the time
cost for 3961148 calls of Packet.__init__ dcrease from 17s to 4s, according
to cProfile.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/emulate/traffic.py
python/samba/tests/emulate/traffic_packet.py