Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf6c75a4 authored by Sanna Catherine de Treville Wager's avatar Sanna Catherine de Treville Wager
Browse files

Moved dump from NBLog to ReportPerformance

Minor cleanup

Test: dumpsys media.log
Change-Id: Ib4d12f6e20c04ecb3344290083ea65a3fe1e47e0
parent a80649ad
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@
#include <climits>
#include <deque>
#include <fstream>
// #include <inttypes.h>
#include <iostream>
#include <math.h>
#include <numeric>
@@ -941,22 +940,8 @@ void NBLog::MergeReader::getAndProcessSnapshot()
    getAndProcessSnapshot(*snap);
}

// TODO: move this function to a different class than NBLog::Reader
// writes summary of performance to the console
void NBLog::MergeReader::dump(int fd, size_t indent)
{
    mFd = fd;
    mIndent = indent;
    String8 body, timestamp;
    // TODO: check: is the FIXME below still a problem?
    // FIXME: this is not thread safe
    for (auto & threadReport : mThreadPerformanceAnalysis) {
        threadReport.second.reportPerformance(&body);
    }
    if (!body.isEmpty()) {
        ALOGD("body is not empty");
        dumpLine(timestamp, body);
    }
void NBLog::MergeReader::dump(int fd, int indent) {
    ReportPerformance::dump(fd, indent, mThreadPerformanceAnalysis);
}

// Writes a string to the console
+21 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include <media/nbaio/NBLog.h>
#include <media/nbaio/PerformanceAnalysis.h>
#include <media/nbaio/ReportPerformance.h>
// #include <utils/CallStack.h> // used to print callstack
#include <utils/Log.h>
#include <utils/String8.h>

@@ -242,7 +241,7 @@ void PerformanceAnalysis::testFunction() {
// TODO Make it return a std::string instead of modifying body --> is this still relevant?
// TODO consider changing all ints to uint32_t or uint64_t
// TODO: move this to ReportPerformance, probably make it a friend function of PerformanceAnalysis
void PerformanceAnalysis::reportPerformance(String8 *body, int maxHeight) {
void PerformanceAnalysis::reportPerformance(String8 *body, int maxHeight) const {
    if (mHists.empty()) {
        ALOGD("reportPerformance: mHists is empty");
        return;
@@ -346,6 +345,26 @@ void PerformanceAnalysis::alertIfGlitch(const std::vector<int64_t> &samples) {
    return;
}

//------------------------------------------------------------------------------

// writes summary of performance into specified file descriptor
void dump(int fd, int indent, const std::map<int, PerformanceAnalysis>
          &threadPerformanceAnalysis) {
    String8 body;
    for (auto & thread : threadPerformanceAnalysis) {
        thread.second.reportPerformance(&body);
    }
    if (!body.isEmpty()) {
        dumpLine(fd, indent, body);
        body.clear();
    }
}

// Writes a string into specified file descriptor
void dumpLine(int fd, int indent, const String8 &body) {
    dprintf(fd, "%.*s%s \n", indent, "", body.string());
}

} // namespace ReportPerformance

}   // namespace android
+3 −3
Original line number Diff line number Diff line
@@ -452,10 +452,11 @@ public:

        // get snapshot of readers fifo buffer, effectively consuming the buffer
        std::unique_ptr<Snapshot> getSnapshot();
        // print a summary of the performance to the console

        bool     isIMemory(const sp<IMemory>& iMemory) const;

    protected:
        // print a summary of the performance to the console
        void    dumpLine(const String8& timestamp, String8& body);
        EntryIterator   handleFormat(const FormatEntry &fmtEntry,
                                     String8 *timestamp,
@@ -544,8 +545,7 @@ public:
    public:
        MergeReader(const void *shared, size_t size, Merger &merger);

        // TODO: consider moving dump to ReportPerformance
        void dump(int fd, size_t indent = 0);
        void dump(int fd, int indent = 0);
        // process a particular snapshot of the reader
        void getAndProcessSnapshot(Snapshot & snap);
        // call getSnapshot of the content of the reader's buffer and process the data
+6 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public:
    // input: series of short histograms. Generates a string of analysis of the buffer periods
    // TODO: WIP write more detailed analysis
    // FIXME: move this data visualization to a separate class. Model/view/controller
    void reportPerformance(String8 *body, int maxHeight = 10);
    void reportPerformance(String8 *body, int maxHeight = 10) const;

    // TODO: delete this. temp for testing
    void testFunction();
@@ -134,6 +134,11 @@ private:

};

void dump(int fd, int indent, const std::map<int, PerformanceAnalysis>
          &threadPerformanceAnalysis);

void dumpLine(int fd, int indent, const String8 &body);

} // namespace ReportPerformance

}   // namespace android