This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sort a foreach on a stat value?


joshua.i.stone wrote:

> Do we have a syntax to sort a foreach based on a stat value?  [...]

Not at this time.


> [...]
> The scalable, per-cpu way to do this is:
> 
> global stat
> probe my.event { stat[tid()]<<<1 }
> probe end {
>   foreach(tid in stat-) // sort by value -> ???
>     printf("%d: %d\n", tid, @count(stat[tid]))
> }

Since the reporting phase does not need to be as "scalable" (fast) as
the accumulation phase, perhaps one could do this thusly today:

 global stat, stat_counts
 probe my.event { stat[tid()]<<<1 }
 probe end {
   foreach (tid in stat) // sort by value -> ???
     stat_counts[tid] = @count(stat[tid])
   foreach (tid in stat_counts-)
     printf("%d: %d\n", tid, stat_counts[tid]) # and/or @avg(stat[tid])) etc.
 }


> Along the same lines, it would be extremely useful to be able to do
> "cascading" sort - i.e. sort by more than one field.

If the runtime provided such an facility, one might imagine the script syntax
exposing it thusly:
  foreach ([x1+, x2--, y2+++] in array----) { ... } 
encoding the cascading order in the length of those +/- suffixes.

- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]