delete operator to delete elements in an array, or an entire array. Consider the following example:Example 3.18. noncumulative-vfsreads.stp
global readsprobe vfs.read{ reads[execname()] ++}probe timer.s(3){ foreach (count in reads) printf("%s : %d \n", count, reads[count]) delete reads}delete reads statement clears the reads array within the probe.Note
global reads, totalreadsprobe vfs.read{ reads[execname()] ++ totalreads[execname()] ++}probe timer.s(3){ printf("=======\n") foreach (count in reads-) printf("%s : %d \n", count, reads[count]) delete reads}probe end{ printf("TOTALS\n") foreach (total in totalreads-) printf("%s : %d \n", total, totalreads[total])}reads and totalreads track the same information, and are printed out in a similar fashion. The only difference here is that reads is cleared every 3-second period, whereas totalreads keeps growing.