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

Commit cbb331be authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "GpuStats: rename an api and add unit tests"

parents 3d546bd5 fdd7e782
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -52,8 +52,9 @@ void GpuService::setGpuStats(const std::string& driverPackageName,
                             int64_t driverBuildTime, const std::string& appPackageName,
                             const int32_t vulkanVersion, GpuStatsInfo::Driver driver,
                             bool isDriverLoaded, int64_t driverLoadingTime) {
    mGpuStats->insert(driverPackageName, driverVersionName, driverVersionCode, driverBuildTime,
                      appPackageName, vulkanVersion, driver, isDriverLoaded, driverLoadingTime);
    mGpuStats->insertDriverStats(driverPackageName, driverVersionName, driverVersionCode,
                                 driverBuildTime, appPackageName, vulkanVersion, driver,
                                 isDriverLoaded, driverLoadingTime);
}

status_t GpuService::getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const {
+7 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "gpuservice_unittest"
    }
  ]
}
+10 −11
Original line number Diff line number Diff line
@@ -74,10 +74,11 @@ static void addLoadingTime(GpuStatsInfo::Driver driver, int64_t driverLoadingTim
    }
}

void GpuStats::insert(const std::string& driverPackageName, const std::string& driverVersionName,
                      uint64_t driverVersionCode, int64_t driverBuildTime,
                      const std::string& appPackageName, const int32_t vulkanVersion,
                      GpuStatsInfo::Driver driver, bool isDriverLoaded, int64_t driverLoadingTime) {
void GpuStats::insertDriverStats(const std::string& driverPackageName,
                                 const std::string& driverVersionName, uint64_t driverVersionCode,
                                 int64_t driverBuildTime, const std::string& appPackageName,
                                 const int32_t vulkanVersion, GpuStatsInfo::Driver driver,
                                 bool isDriverLoaded, int64_t driverLoadingTime) {
    ATRACE_CALL();

    std::lock_guard<std::mutex> lock(mLock);
@@ -191,6 +192,11 @@ void GpuStats::dump(const Vector<String16>& args, std::string* result) {
        dumpAll = false;
    }

    if (dumpAll) {
        dumpGlobalLocked(result);
        dumpAppLocked(result);
    }

    if (argsSet.count("--clear")) {
        bool clearAll = true;

@@ -208,13 +214,6 @@ void GpuStats::dump(const Vector<String16>& args, std::string* result) {
            mGlobalStats.clear();
            mAppStats.clear();
        }

        dumpAll = false;
    }

    if (dumpAll) {
        dumpGlobalLocked(result);
        dumpAppLocked(result);
    }
}

+6 −5
Original line number Diff line number Diff line
@@ -32,11 +32,12 @@ public:
    GpuStats() = default;
    ~GpuStats() = default;

    // Insert new gpu stats into global stats and app stats.
    void insert(const std::string& driverPackageName, const std::string& driverVersionName,
                uint64_t driverVersionCode, int64_t driverBuildTime,
                const std::string& appPackageName, const int32_t vulkanVersion,
                GpuStatsInfo::Driver driver, bool isDriverLoaded, int64_t driverLoadingTime);
    // Insert new gpu driver stats into global stats and app stats.
    void insertDriverStats(const std::string& driverPackageName,
                           const std::string& driverVersionName, uint64_t driverVersionCode,
                           int64_t driverBuildTime, const std::string& appPackageName,
                           const int32_t vulkanVersion, GpuStatsInfo::Driver driver,
                           bool isDriverLoaded, int64_t driverLoadingTime);
    // Insert target stats into app stats or potentially global stats as well.
    void insertTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
                           const GpuStatsInfo::Stats stats, const uint64_t value);
+34 −0
Original line number Diff line number Diff line
// Copyright 2020 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

cc_test {
    name: "gpuservice_unittest",
    test_suites: ["device-tests"],
    sanitize: {
        address: true,
    },
    srcs: [
        "GpuStatsTest.cpp",
    ],
    shared_libs: [
        "libcutils",
        "libgfxstats",
        "libgraphicsenv",
        "liblog",
        "libutils",
    ],
    static_libs: [
        "libgmock",
    ],
}
Loading