[llvm] r323800 - [XRay] fix 99th percentile lookups by sorting the array correctly
Martin Pelikan via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 10:18:52 PST 2018
Author: pelikan
Date: Tue Jan 30 10:18:51 2018
New Revision: 323800
URL: http://llvm.org/viewvc/llvm-project?rev=323800&view=rev
Log:
[XRay] fix 99th percentile lookups by sorting the array correctly
Summary:
It was a copy-paste typo, sorting only to the 90th percentile twice.
Now, it only sorts the array prefix once, and extracts what we need.
Reviewers: dberris, kpw, eizan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D42690
Modified:
llvm/trunk/tools/llvm-xray/xray-account.cc
Modified: llvm/trunk/tools/llvm-xray/xray-account.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-xray/xray-account.cc?rev=323800&r1=323799&r2=323800&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-xray/xray-account.cc (original)
+++ llvm/trunk/tools/llvm-xray/xray-account.cc Tue Jan 30 10:18:51 2018
@@ -237,16 +237,19 @@ ResultRow getStats(std::vector<uint64_t>
auto MinMax = std::minmax_element(Timings.begin(), Timings.end());
R.Min = *MinMax.first;
R.Max = *MinMax.second;
+ R.Count = Timings.size();
+
auto MedianOff = Timings.size() / 2;
std::nth_element(Timings.begin(), Timings.begin() + MedianOff, Timings.end());
R.Median = Timings[MedianOff];
+
auto Pct90Off = std::floor(Timings.size() * 0.9);
std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
R.Pct90 = Timings[Pct90Off];
+
auto Pct99Off = std::floor(Timings.size() * 0.99);
- std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
+ std::nth_element(Timings.begin(), Timings.begin() + Pct99Off, Timings.end());
R.Pct99 = Timings[Pct99Off];
- R.Count = Timings.size();
return R;
}
More information about the llvm-commits
mailing list