WLAN-Pi / wlanpi-profiler

Wi-Fi client capabilities analyzer tool built for the WLAN Pi
BSD 3-Clause "New" or "Revised" License
23 stars 8 forks source link

Micro-optimizing #118

Closed joshschmelzle closed 1 year ago

joshschmelzle commented 1 year ago

There are some performance issues that may be helped through some micro-optimization. As a note, the Python version context for this issue is 3.9 because that is what WLAN Pi ships with.

Constructs to look for:

  1. Loop-invariant statements.
  2. Utilize comprehensions.
  3. Select the right Data Structures. There is overhead with certain data tpes.
  4. Function calls have significant overhead. Avoid small functions in hot code. Hot code means using them in a loop. Small utility functions called in a hot loop have performance hits. Need to think about in-lining some of the instructions. Look at pyinline. https://github.com/tonybaloney/pyinline

Before we get started, we need to benchmark and baseline. When we actually make changes, try to make small atomic changes.

Originally posted by @joshschmelzle in https://github.com/WLAN-Pi/wlanpi-profiler/issues/103#issuecomment-1285485633