def _profile(prof_id, func):
  # Note that some distro don't come with pstats
  import pstats
  try:
    import cProfile as profile
  except ImportError:
    import profile

  PROF_DAT = '/tmp/desktop-profile-%s.dat' % (prof_id,)

  prof = profile.Profile()
  try:
    prof.runcall(func)
  finally:
    if os.path.exists(PROF_DAT):
      os.remove(PROF_DAT)
    prof.dump_stats(PROF_DAT)
    # Sort the calls by time spent and show top 50
    pstats.Stats(PROF_DAT).sort_stats('time').print_stats(50)
    print >>sys.stderr, "Complete profile data in %s" % (PROF_DAT,)
Write soil parameter file for current simulation based on basin shapefile.
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/manage_entry.py/_profile--crossover with--dataset/ETHPy150Open nasa/RHEAS/src/vic/vic.py/VIC.writeSoilFile