neutron-lib/neutron_lib/utils
Antoni Segura Puimedon b5b7131f4e
net_utils: Speed up mac address generation
Using getrandbits supposes a huge speedup:

Py2
In [2]: %timeit random.randint(0, 0xff)
The slowest run took 28.53 times longer than the fastest.
This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 769 ns per loop

In [3]: %timeit random.getrandbits(8)
The slowest run took 54.81 times longer than the fastest.
This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 126 ns per loop

Py3

In [3]: %timeit random.randint(0, 0xff)
The slowest run took 288.80 times longer than the fastest.
This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 1.15 µs per loop

In [4]: %timeit random.getrandbits(8)
The slowest run took 29.15 times longer than the fastest.
This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 109 ns per loop

Change-Id: Id6b86c7d2cf88feb81b79862d93f8d06aeb8fa63
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
2017-10-13 13:32:42 +02:00
..
__init__.py Start migration of utility methods 2016-08-19 12:28:31 +01:00
file.py Enable module reference 2017-07-05 12:09:10 +09:00
helpers.py Enable module reference 2017-07-05 12:09:10 +09:00
host.py Enable module reference 2017-07-05 12:09:10 +09:00
net.py net_utils: Speed up mac address generation 2017-10-13 13:32:42 +02:00
runtime.py Enable module reference 2017-07-05 12:09:10 +09:00