microsoft-performance-toolkit-sdk
microsoft-performance-toolkit-sdk copied to clipboard
Add ResourceTimeRange.
ResourceTimeRange
ResourceTimeRange
is a new duration-like data type that is designed to compute accurately total resource usage when aggregated as Sum
.
In particular, Sum
aggregation of ResourceTimeRange
values avoids both:
- overestimation of total usage in the presence of nested activities on the same resource.
- underestimation of total usage in the presence of activities running concurrently on different resources.
Differences from current Duration-like Data Types
Two other duration-like data types already exist in the Microsoft Performance Toolkit SDK, TimeStampDelta
and TimeRange
. They either overestimate or underestimate the total usage ResourceTimeRange
computes, as follows:
-
TimeStampDelta
values sum as the plain sum of durations, irrespective of potential nesting of the respective activities on the same resource. As such, they overestimate resource usage in the presence of nested activities on the same resource. However,TimeStampDelta
correctly accounts for parallel resource usage in the presence of activities running concurrently on different resources. -
TimeRange
values sum as the total duration of the union of their time intervals, irrespective of potentially parallelism of the respective activities running on different resources. As such, they underestimate resource usage in the presence of activities running concurrently on different resources. However,TimeRange
correctly eliminates resource usage duplication in the presence of nested activities on the same resource.
ResourceTimeRange
combines the strengths of TimeStampDelta
and TimeRange
while eliminating their weaknesses for the use case of computing the total resource usage.
New Data Type Details
Technically, ResourceTimeRange
contains both an int
resource id and a TimeRange
. The resource id interpretation can vary from column to column, so that different columns in the same or different tables could perform total resource usage computation on CPUs, disks, processes, threads, etc., depending on the corresponding resource affinity/interaction interpretation of the respective entities in the rows of the table.
Like TimeRange
, ResourceTimeRange
is compared and presented as a TimeStampDelta
, offering an alternative Sum
aggregation to TimeStampDelta
's plain summing of durations.
ResourceTimeRange
values sum as the sum of across resources of the total duration of the union of their time intervals on the same resource. As such, they behave like TimeRange
values on the same resource and like TimeStampDelta
values across different resources.
ResourceTimeRange
values also aggregate as Min
, Max
, Count
, Unique Count
, similar to TimeRange
values.