|
8 | 8 |
|
9 | 9 |
|
10 | 10 | 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. |
13 | 29 | """
|
14 | 30 |
|
15 | 31 | def __init__(self, definitions, events):
|
@@ -277,6 +293,19 @@ def _match_caller_callee(self):
|
277 | 293 | )
|
278 | 294 |
|
279 | 295 | 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 | + |
280 | 309 | # if no columns are specified by the user, then we calculate
|
281 | 310 | # inclusive metrics for all the numeric columns in the trace
|
282 | 311 | columns = self.numeric_cols if columns is None else columns
|
@@ -312,6 +341,19 @@ def calc_inc_metrics(self, columns=None):
|
312 | 341 | self.inc_metrics.append(metric_col_name)
|
313 | 342 |
|
314 | 343 | 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 | + |
315 | 357 | # calculate exc metrics for all numeric columns if not specified
|
316 | 358 | columns = self.numeric_cols if columns is None else columns
|
317 | 359 |
|
|
0 commit comments