| 
   |||
| 
 2. Types, Operators, and Expressions 8. Type and Constant Definitions 34. Statically Defined Tracing for User Applications  | 
      
	 Use AggregationsAs discussed in Chapter 9, Aggregations, DTrace's aggregations allow for a scalable way of aggregating data. Associative arrays might appear to offer similar functionality to aggregations. However, by nature of being global, general-purpose variables, they cannot offer the linear scalability of aggregations. You should therefore prefer to use aggregations over associative arrays when possible. The following example is not recommended: syscall:::entry
{
    totals[execname]++;
}
syscall::rexit:entry
{
    printf("%40s %d\n", execname, totals[execname]);
    totals[execname] = 0;
}The following example is preferable: syscall:::entry
{
    @totals[execname] = count();
}
END
{
    printa("%40s %@d\n", @totals);
}
          | 
   ||
         
  |