Change file structure and data structure size
Histograms and related data structures can
store up to 10 hours worth of data. Fixed
histogram logging elapsed time count and
resolution
Test: dumpsys media.log
Change-Id: Ibb394273b7b1be4c791f9dbe64a32a7436714a9d
diff --git a/media/libnbaio/ReportPerformance.cpp b/media/libnbaio/ReportPerformance.cpp
index e64a6d3..efc1b84 100644
--- a/media/libnbaio/ReportPerformance.cpp
+++ b/media/libnbaio/ReportPerformance.cpp
@@ -37,6 +37,10 @@
namespace ReportPerformance {
+
+// TODO: use a function like this to extract logic from writeToFile
+// https://stackoverflow.com/a/9279620
+
// Writes outlier intervals, timestamps, and histograms spanning long time intervals to file.
// TODO: write data in binary format
void writeToFile(const std::deque<std::pair<timestamp, Histogram>> &hists,
@@ -80,13 +84,18 @@
// each histogram is written as a line where the first value is the timestamp and
// subsequent values are pairs of buckets and counts. Each value is separated
// by a comma, and each histogram is separated by a newline.
- for (const auto &hist : hists) {
- hfs << hist.first << ", ";
- for (const auto &bucket : hist.second) {
- hfs << bucket.first / static_cast<double>(kJiffyPerMs)
- << ", " << bucket.second << ", ";
+ for (auto hist = hists.begin(); hist != hists.end(); ++hist) {
+ hfs << hist->first << ", ";
+ for (auto bucket = hist->second.begin(); bucket != hist->second.end(); ++bucket) {
+ hfs << bucket->first / static_cast<double>(kJiffyPerMs)
+ << ", " << bucket->second;
+ if (std::next(bucket) != end(hist->second)) {
+ hfs << ", ";
+ }
}
- hfs << "\n";
+ if (std::next(hist) != end(hists)) {
+ hfs << "\n";
+ }
}
hfs.close();
@@ -110,8 +119,11 @@
return;
}
// peaks are simply timestamps separated by commas
- for (const auto &peak : peakTimestamps) {
- pfs << peak << ", ";
+ for (auto peak = peakTimestamps.begin(); peak != peakTimestamps.end(); ++peak) {
+ pfs << *peak;
+ if (std::next(peak) != end(peakTimestamps)) {
+ pfs << ", ";
+ }
}
pfs.close();
}