diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2020-07-26 14:00:15 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2020-07-26 14:08:06 +0300 |
commit | ed5a6b9305145fd073d046d6e9814ffb70c5fdbe (patch) | |
tree | 701bc6ec53f4b2106b2785fd3613273851c7099b /llvm/tools/llvm-xray | |
parent | 18df607dbeb41451f5842f46e9b7a67baf759d5e (diff) | |
download | llvm-ed5a6b9305145fd073d046d6e9814ffb70c5fdbe.zip llvm-ed5a6b9305145fd073d046d6e9814ffb70c5fdbe.tar.gz llvm-ed5a6b9305145fd073d046d6e9814ffb70c5fdbe.tar.bz2 |
[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.
Diffstat (limited to 'llvm/tools/llvm-xray')
-rw-r--r-- | llvm/tools/llvm-xray/xray-account.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/tools/llvm-xray/xray-account.cpp b/llvm/tools/llvm-xray/xray-account.cpp index fcac33b..21da53f 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; } |