piiswrong commented on a change in pull request #8972: Profiling enhancements, 
python API, vtune and chrome tracing objects, etc.
URL: https://github.com/apache/incubator-mxnet/pull/8972#discussion_r168573446
 
 

 ##########
 File path: python/mxnet/profiler.py
 ##########
 @@ -52,7 +58,298 @@ def profiler_set_state(state='stop'):
     state2int = {'stop': 0, 'run': 1}
     check_call(_LIB.MXSetProfilerState(ctypes.c_int(state2int[state])))
 
-def dump_profile():
+def dump(finished=True):
     """Dump profile and stop profiler. Use this to save profile
-    in advance in case your program cannot exit normally."""
-    check_call(_LIB.MXDumpProfile())
+    in advance in case your program cannot exit normally.
+
+    Parameters
+    ----------
+    finished : boolean
+        Indicates whether to stop statistical output (dumping) after this dump.
+        Default is True
+    """
+    fin = 1 if finished is True else False
+    check_call(_LIB.MXDumpProfile(fin))
+
+def aggregate_stats_str(reset=False):
+    """Return a printable string of aggregate profile stats.
+    Parameters
+    ----------
+    reset: boolean
+        Indicates whether to clean aggeregate statistical data collected up to 
this point
+    """
+    debug_str = ctypes.c_char_p()
+    do_reset = 1 if reset is True else 0
+    check_call(_LIB.MXAggregateProfileStatsPrint(ctypes.byref(debug_str), 
int(do_reset)))
+    return py_str(debug_str.value)
+
+def pause():
+    check_call(_LIB.MXProfilePause(int(1)))
+
+def resume():
+    check_call(_LIB.MXProfilePause(int(0)))
+
+class Domain(object):
+    """Profiling domain, used to group sub-objects like tasks, counters, etc 
into categories
+    Serves as part of 'categories' for chrome://tracing
+    Note: Domain handles are never destroyed.
+    """
+    def __init__(self, name):
+        """Profiling Domain class constructor
+            Parameters
+            ----------
+            name : string
+                Name of the domain
+        """
+        self.name = name
+        self.handle = ProfileHandle()
+        check_call(_LIB.MXProfileCreateDomain(c_str(self.name), 
ctypes.byref(self.handle)))
+
+    def __str__(self):
+        return self.name
+
+    def new_task(self, name):
+        """Create new Task object owned by this domain
+            Parameters
+            ----------
+            name : string
+                Name of the task
+        """
+        return Task(self, name)
+
+    def new_frame(self, name):
+        """Create new Frame object owned by this domain
+            Parameters
+            ----------
+            name : string
+                Name of the frame
+        """
+        return Frame(self, name)
+
+    def new_counter(self, name, value=None):
+        """Create new Counter object owned by this domain
+            Parameters
+            ----------
+            name : string
+                Name of the counter
+        """
+        return Counter(self, name, value)
+
+    def new_marker(self, name):
+        """Create new Marker object owned by this domain
+            Parameters
+            ----------
+            name : string
+                Name of the marker
+        """
+        return Marker(self, name)
+
+class Task(object):
+    """Profiling Task class
+    A task is a logical unit of work performed by a particular thread.
+    Tasks can nest; thus, tasks typically correspond to functions, scopes, or 
a case block
+    in a switch statement.
+    You can use the Task API to assign tasks to threads.
+    """
+    def __init__(self, domain, name):
+        """Profiling Task class constructor.
+            Parameters
 
 Review comment:
   I don't know if this would work. AFAIK most other APIs put this in the class 
docstring

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to