It was a copy-paste typo, sorting only to the 90th percentile twice.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 14395 Build 14395: arc lint + arc unit
Event Timeline
Good catch! See other comment though.
tools/llvm-xray/xray-account.cc | ||
---|---|---|
244–248 | I don't think this does the same thing as the original code did (or what it was intended to do). std::nth_element doesn't actually sort the elements before the n'th element. It just guarantees that the element that would have been at the n'th position is there. We still need the two other calls to std::nth_element that would find the correct median, 90pct, and 99pct. |
tools/llvm-xray/xray-account.cc | ||
---|---|---|
244–248 | Ah, it only partially sorts them. I mis-read that on the internet (first time I saw that function). Sorry, fixed. |
tools/llvm-xray/xray-account.cc | ||
---|---|---|
244–248 | Okay, now the problem is that calls to nth_element may re-order the elements before the n'th element. :) If you want to make this cleaner with less repetition (and less potential for error), you might consider breaking this out into a function that encapsulates the nth_element and lookup to return the actual value. Something like: R.Median = findPercentile(Timings, MedianOff); R.Pct90 = findPercentile(Timings, Pct90Off); ... Then you can hide the nth_element call. |
reorder like it used to be
tools/llvm-xray/xray-account.cc | ||
---|---|---|
244–248 | Hahaha, gentle reminder I should probably go home. :-) Thanks, fixed so it looks more like it used to. No need for special functions here IMHO. |
I don't think this does the same thing as the original code did (or what it was intended to do).
std::nth_element doesn't actually sort the elements before the n'th element. It just guarantees that the element that would have been at the n'th position is there.
We still need the two other calls to std::nth_element that would find the correct median, 90pct, and 99pct.