Aggregates

Aggregates are DTrace’s way of accumulating a lot of individual pieces of data into a more useful overall view. Seeing individual read() times can be useful, if a bit voluminous. Having a min / max / average of read times may be much more interesting.

The syntax for using a DTrace aggregate looks a bit like using array.

@​n​a​m​e​[​k​e​y​]​ ​=​ ​a​g​g​f​u​n​c​(​)​;​

The leading at-sign means that an aggregate is being used, and the assignment is a function rather than an expression. There are a number of aggregating functions:

count()

Keeps count of the number of times it is called.

sum(expression)

Accumulates the total value of the expression over time.

avg(expression)

Accumulates the arithmetic average of the expression over time. ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.