Skip to content

Commit d2b81d7

Browse files
committed
Merge branch 'docs' of https://github.com/hpcgroup/pipit into docs
2 parents 19fe6c9 + c81b9a4 commit d2b81d7

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.cache
33
.pytest_cache
44
.ipynb_checkpoints
5+
_build

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# add these directories to sys.path here. If the directory is relative to the
1616
# documentation root, use os.path.abspath to make it absolute, like shown here.
1717
#
18-
# import os
18+
import os
1919
import sys
2020

21-
# sys.path.insert(0, os.path.abspath('.'))
21+
sys.path.insert(0, os.path.abspath("../"))
2222

2323
# The name of the Pygments (syntax highlighting) style to use.
2424
from pygments.styles.default import DefaultStyle

pipit/trace.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,24 @@
88

99

1010
class Trace:
11-
"""A trace dataset is read into an object of this type, which includes one
12-
or more dataframes.
11+
"""
12+
A Trace object represents trace data collected during the execution of a program.
13+
It provides an organized and structured view of the data collected, with DataFrames
14+
for both the trace data and metadata.
15+
16+
The most important DataFrame in the Trace object is the `events` DataFrame,
17+
which holds a record of every event as it occurs, including essential details like
18+
event type, timestamp, and the process in which it occurs. These events can be either
19+
"Instant" events that take place at a particular time point or pairs of "Enter" and
20+
"Leave" events that indicate function intervals.
21+
22+
In addition to providing access to the raw trace data, the Trace object offers
23+
various analysis and visualization operations, making it easy to sift through the
24+
data and extract insights. These operations include trace filtering, grouping,
25+
aggregation, and profiling, as well as visualization methods such as call graphs,
26+
flame charts, and communication matrices. With the help of the Trace object,
27+
you can easily navigate complex trace data and gain a deep understanding of
28+
program execution behavior.
1329
"""
1430

1531
def __init__(self, definitions, events):
@@ -277,6 +293,19 @@ def _match_caller_callee(self):
277293
)
278294

279295
def calc_inc_metrics(self, columns=None):
296+
"""
297+
Calculates the specified *inclusive* metrics for each event in the trace, and
298+
stores the results in a new column of the events DataFrame.
299+
300+
For instance, if the specified metric is "Timestamp (ns)", this method creates
301+
a new column called "time.exc", which contains the inclusive time spent in each
302+
function call. The inclusive time of a function call is calculated as the difference
303+
between its "Enter" and "Leave" timestamps, and *includes time spent in any
304+
sub-functions called by that function.*
305+
306+
Note that this method modifies the events DataFrame in place and does not return a new DataFrame.
307+
"""
308+
280309
# if no columns are specified by the user, then we calculate
281310
# inclusive metrics for all the numeric columns in the trace
282311
columns = self.numeric_cols if columns is None else columns
@@ -312,6 +341,19 @@ def calc_inc_metrics(self, columns=None):
312341
self.inc_metrics.append(metric_col_name)
313342

314343
def calc_exc_metrics(self, columns=None):
344+
"""
345+
Calculates the specified *exclusive* metrics for each event in the trace, and
346+
stores the results in a new column of the events DataFrame.
347+
348+
For instance, if the specified metric is "Timestamp (ns)", this method creates
349+
a new column called "time.exc", which contains the exclusive time spent in each
350+
function call. The exclusive time of a function call is calculated as the difference
351+
between its "Enter" and "Leave" timestamps, and does not include time spent in any
352+
sub-functions called by that function.
353+
354+
Note that this method modifies the events DataFrame in place and does not return a new DataFrame.
355+
"""
356+
315357
# calculate exc metrics for all numeric columns if not specified
316358
columns = self.numeric_cols if columns is None else columns
317359

0 commit comments

Comments
 (0)