RE: sort a foreach on a stat value?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

RE: sort a foreach on a stat value?

Stone, Joshua I
Bump.

Nobody has an opinion about this?


Stone, Joshua I wrote:

> Do we have a syntax to sort a foreach based on a stat value?
> Obviously this doesn't make sense for a histogram, but for the
> others, like @count, it seems that this would very often be what a
> user would want to do.
>
> For example - here's an unscalable way to do simple thread profiling:
>
> global stat
> probe my.event { ++stat[tid()] }
> probe end {
>   foreach(tid in stat-) // sort by value -> most active
>     printf("%d: %d\n", tid, stat[tid])
> }
>
> 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]))
> }
>
> But there doesn't seem to be a way to achieve the same sorting.
>
> Along the same lines, it would be extremely useful to be able to do
> "cascading" sort - i.e. sort by more than one field.
>
>
> Josh