[llvm] ed5a6b9 - [NFC][XRay] Account: decouple getStats() interface from underlying data structure
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 26 04:08:38 PDT 2020
Author: Roman Lebedev
Date: 2020-07-26T14:08:06+03:00
New Revision: ed5a6b9305145fd073d046d6e9814ffb70c5fdbe
URL: https://github.com/llvm/llvm-project/commit/ed5a6b9305145fd073d046d6e9814ffb70c5fdbe
DIFF: https://github.com/llvm/llvm-project/commit/ed5a6b9305145fd073d046d6e9814ffb70c5fdbe.diff
LOG: [NFC][XRay] Account: decouple getStats() interface from underlying data structure
It doesn't really need to know where Timings are stored, it just needs
to be able to sort them, so MutableArrayRef is enough.
That uncovers an interesting quirk that it relied on
implicit double->int conversion for calculating percentiles.
Added:
Modified:
llvm/tools/llvm-xray/xray-account.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-xray/xray-account.cpp b/llvm/tools/llvm-xray/xray-account.cpp
index fcac33b23d4d..21da53f362b0 100644
--- a/llvm/tools/llvm-xray/xray-account.cpp
+++ b/llvm/tools/llvm-xray/xray-account.cpp
@@ -226,7 +226,7 @@ struct ResultRow {
std::string Function;
};
-ResultRow getStats(std::vector<uint64_t> &Timings) {
+ResultRow getStats(MutableArrayRef<uint64_t> Timings) {
assert(!Timings.empty());
ResultRow R;
R.Sum = std::accumulate(Timings.begin(), Timings.end(), 0.0);
@@ -240,11 +240,13 @@ ResultRow getStats(std::vector<uint64_t> &Timings) {
R.Median = Timings[MedianOff];
auto Pct90Off = std::floor(Timings.size() * 0.9);
- std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
+ std::nth_element(Timings.begin(), Timings.begin() + (uint64_t)Pct90Off,
+ Timings.end());
R.Pct90 = Timings[Pct90Off];
auto Pct99Off = std::floor(Timings.size() * 0.99);
- std::nth_element(Timings.begin(), Timings.begin() + Pct99Off, Timings.end());
+ std::nth_element(Timings.begin(), Timings.begin() + (uint64_t)Pct99Off,
+ Timings.end());
R.Pct99 = Timings[Pct99Off];
return R;
}
More information about the llvm-commits
mailing list