{method 'sumof 'numpy ndarrayobjects : ( {method 'disableof '_lsprof profilerobjectsthis is not especially enlightening with the line_profiler ipython extension activateda new command %lprun is available the only difference in usage is that we must instruct %lprun which function or functions we wish to profile the general syntax is%lprun - func - func statement_to_profile in this casewe want to profile add_and_sumso we runin [ ]%lprun - add_and_sum add_and_sum(xytimer unit - filebook_scripts/prof_mod py functionadd_and_sum at line total time line hits time per hit time line contents ============================================================= def add_and_sum(xy) added summed added sum(axis= return summed you'll probably agree this is much easier to interpret in this case we profiled the same function we used in the statement looking at the module code abovewe could call call_function and profile that as well as add_and_sumthus getting full picture of the performance of the codein [ ]%lprun - add_and_sum - call_function call_function(timer unit - filebook_scripts/prof_mod py functionadd_and_sum at line total time line hits time per hit time line contents ============================================================= def add_and_sum(xy) added summed added sum(axis= return summed filebook_scripts/prof_mod py functioncall_function at line total time line hits time per hit time line contents ============================================================= def call_function() randn( randn( return add_and_sum(xyas general rule of thumbi tend to prefer %prun (cprofilefor "macroprofiling and %lprun (line_profilerfor "microprofiling it' worthwhile to have good understanding of both tools software development tools www it-ebooks info