[PATCH] D42690: [XRay] fix 99th percentile lookups by sorting the array correctly

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 09:16:37 PST 2018


pelikan updated this revision to Diff 131981.
pelikan added a comment.

nth_element doesn't actually order things on either side; put them back


Repository:
  rL LLVM

https://reviews.llvm.org/D42690

Files:
  tools/llvm-xray/xray-account.cc


Index: tools/llvm-xray/xray-account.cc
===================================================================
--- tools/llvm-xray/xray-account.cc
+++ tools/llvm-xray/xray-account.cc
@@ -238,13 +238,13 @@
   R.Min = *MinMax.first;
   R.Max = *MinMax.second;
   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() + MedianOff, Timings.end());
   std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
+  std::nth_element(Timings.begin(), Timings.begin() + Pct99Off, Timings.end());
+  R.Median = Timings[MedianOff];
+  R.Pct90 = Timings[Pct90Off];
   R.Pct99 = Timings[Pct99Off];
   R.Count = Timings.size();
   return R;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42690.131981.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180130/3ec318ed/attachment.bin>


More information about the llvm-commits mailing list