Skip to content

Commit

Permalink
add docs string and clear profiles after show or dump
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Sep 13, 2014
1 parent 4f8309d commit dadee1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/pyspark/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,23 +2147,28 @@ def _jrdd(self):

@classmethod
def show_profile(cls):
""" Print the profile stats to stdout """
for id, acc in cls._created_profiles:
stats = acc.value
if stats:
print "="*60
print "=" * 60
print "Profile of RDD<id=%d>" % id
print "="*60
print "=" * 60
stats.sort_stats("tottime", "cumtime").print_stats()
cls._created_profiles = []

@classmethod
def dump_profile(cls, dump_path):
""" Dump the profile stats into directory `dump_path`
"""
if not os.path.exists(dump_path):
os.makedirs(dump_path)
for id, acc in cls._created_profiles:
stats = acc.value
if stats:
path = os.path.join(dump_path, "rdd_%d.pstats" % id)
stats.dump_stats(path)
cls._created_profiles = []

def id(self):
if self._id is None:
Expand Down

0 comments on commit dadee1a

Please sign in to comment.