--- title: "Optimization" slug: "optimization" updated: 2021-10-17T18:07:16Z published: 2021-10-17T18:07:16Z canonical: "docs.imat.io/optimization" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.imat.io/llms.txt > Use this file to discover all available pages before exploring further. # Optimization ``` import cProfile def startProfiling(pr): pr.enable() def stopProfiling(pr): import pstats, cStringIO pr.disable() s = cStringIO.StringIO() ps = pstats.Stats(pr, stream=s).sort_stats('cumulative') ps.print_stats() print(s.getvalue()) if enable_profiling: pr = cProfile.Profile() startProfiling(pr) ... if enable_profiling: stopProfiling(pr) setSSQueryDefaults(timeoutsec=600 ```