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
Post a Comment