performance - How do I count bytecodes in Python so I can modify sys.setcheckinterval appropriately -


i have port scanning application uses work queues , threads.

it uses simple tcp connections , spends lot of time waiting packets come (up half second). threads don't need execute (i.e. first half sends packet, context switch, stuff, comes thread has network data waiting it).

i suspect can improve performance modifying sys.setcheckinterval default of 100 (which lets 100 bytecodes execute before switching thread).

but without knowing how many bytecodes executing in thread or function i'm flying blind , guessing values, testing , relying on testing shows measurable difference (which difficult since amount of code being executed minimal; simple socket connection, network jitter affect measurements more changing sys.setcheckinterval).

thus find out how many bytecodes in code executions (i.e. total function or in execution of thread) can make more intelligent guesses @ set sys.setcheckinterval to.

for higher level (method, class) wise, dis module should help.

but if 1 needs finer grain, tracing unavoidable. tracing operate line line basis explained here great hack dive deeper @ bytecode level. hats off ned batchelder.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -