Key 2: Identifying application performance bottlenecks.
We should not rely on our intuition on how to optimize application. There are two major ways for logic slowdown; one is CPU time taken, and the second is the wait for results from some other entity. By profiling, we can find out such cases in which we can tweak logic, and language syntax to get better performance on the same hardware. The following code is a
showtime decorator that I use to calculate the time taken to call a function. It is simple and effective to get rapid answers:
from datetime import datetime,timedelta from functools import wraps import time def showtime(func): @wraps(func) def wrap(*args,**kwargs): st = time.time() #time clock can be used ...