Optimization
  • 17 Oct 2021
  • 1 Minute to read
  • Dark
    Light

Optimization

  • Dark
    Light

Article summary

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

Was this article helpful?

What's Next