decorator pattern time abides long enough for those who make use of it --leonardo da vinci as you become more experiencedyou will find yourself moving beyond the type of problems that can easily be solved with the most general programming constructs at such timeyou will realize you need different tool set this focuses on one such tool when you are trying to squeeze every last drop of performance out of your machineyou need to know exactly how long specific piece of code takes to execute you must save the system time before you initiate the code to be profiledthen execute the codeonce it has concludedyou must save the second system timestamp finallysubtract the first time from the second to obtain the time elapsed during the execution look at this example for calculating fibonacci numbers fib py import time start_time time time(fibprev fib for num in range( )fibprevfib fibfib fibprev end_time time time(print("[time elapsed for {}{}format(nend_time start_time)print("fibonacci number for {}{}format(nfibiter( ))(cwessel badenhorst badenhorstpractical python design patterns