Loading services/powermanager/PowerHalWrapper.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -117,8 +117,7 @@ HalResult AidlHalWrapper::setBoost(Boost boost, int32_t durationMs) { bool isSupported = false; auto isSupportedRet = mHandle->isBoostSupported(boost, &isSupported); if (!isSupportedRet.isOk()) { ALOGV("Skipped setBoost %s because Power HAL is not available to check " "support", ALOGV("Skipped setBoost %s because Power HAL is not available to check support", toString(boost).c_str()); return HalResult::FAILED; } Loading Loading @@ -149,8 +148,7 @@ HalResult AidlHalWrapper::setMode(Mode mode, bool enabled) { bool isSupported = false; auto isSupportedRet = mHandle->isModeSupported(mode, &isSupported); if (!isSupportedRet.isOk()) { ALOGV("Skipped setMode %s because Power HAL is not available to check " "support", ALOGV("Skipped setMode %s because Power HAL is not available to check support", toString(mode).c_str()); return HalResult::FAILED; } Loading services/powermanager/benchmarks/Android.bp 0 → 100644 +39 −0 Original line number Diff line number Diff line // Copyright (C) 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_benchmark { name: "libpowermanager_benchmarks", srcs: [ "main.cpp", "PowerHalAidlBenchmarks.cpp", "PowerHalControllerBenchmarks.cpp", "PowerHalHidlBenchmarks.cpp", ], shared_libs: [ "libbase", "libbinder", "libhidlbase", "liblog", "libpowermanager", "libutils", "android.hardware.power@1.0", "android.hardware.power@1.1", "android.hardware.power-cpp", ], cflags: [ "-Wall", "-Werror", "-Wextra", ], } services/powermanager/benchmarks/AndroidTest.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 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. --> <configuration description="Config for libpowermanager benchmarks"> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="libpowermanager_benchmarks->/data/benchmarktest/benchmark" /> </target_preparer> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-metric-instrumentation" /> <test class="com.android.tradefed.testtype.GoogleBenchmarkTest" > <option name="native-benchmark-device-path" value="/data/benchmarktest" /> <option name="benchmark-module-name" value="benchmark" /> </test> </configuration> services/powermanager/benchmarks/PowerHalAidlBenchmarks.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright (C) 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. */ #define LOG_TAG "PowerHalAidlBenchmarks" #include <android/hardware/power/Boost.h> #include <android/hardware/power/IPower.h> #include <android/hardware/power/Mode.h> #include <benchmark/benchmark.h> #include <binder/IServiceManager.h> using android::hardware::power::Boost; using android::hardware::power::IPower; using android::hardware::power::Mode; using namespace android; template <class R, class... Args0, class... Args1> static void runBenchmark(benchmark::State& state, R (IPower::*fn)(Args0...), Args1&&... args1) { sp<IPower> hal = waitForVintfService<IPower>(); if (hal == nullptr) { ALOGI("Power HAL AIDL not available, skipping test..."); return; } while (state.KeepRunning()) { (*hal.*fn)(std::forward<Args1>(args1)...); } } static void BM_PowerHalAidlBenchmarks_isBoostSupported(benchmark::State& state) { bool isSupported; runBenchmark(state, &IPower::isBoostSupported, Boost::INTERACTION, &isSupported); } static void BM_PowerHalAidlBenchmarks_isModeSupported(benchmark::State& state) { bool isSupported; runBenchmark(state, &IPower::isModeSupported, Mode::INTERACTIVE, &isSupported); } static void BM_PowerHalAidlBenchmarks_setBoost(benchmark::State& state) { runBenchmark(state, &IPower::setBoost, Boost::INTERACTION, 0); } static void BM_PowerHalAidlBenchmarks_setMode(benchmark::State& state) { runBenchmark(state, &IPower::setMode, Mode::INTERACTIVE, false); } BENCHMARK(BM_PowerHalAidlBenchmarks_isBoostSupported); BENCHMARK(BM_PowerHalAidlBenchmarks_isModeSupported); BENCHMARK(BM_PowerHalAidlBenchmarks_setBoost); BENCHMARK(BM_PowerHalAidlBenchmarks_setMode); services/powermanager/benchmarks/PowerHalControllerBenchmarks.cpp 0 → 100644 +88 −0 Original line number Diff line number Diff line /* * Copyright (C) 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. */ #define LOG_TAG "PowerHalControllerBenchmarks" #include <android/hardware/power/Boost.h> #include <android/hardware/power/Mode.h> #include <benchmark/benchmark.h> #include <powermanager/PowerHalController.h> using android::hardware::power::Boost; using android::hardware::power::Mode; using android::power::PowerHalController; using namespace android; static void BM_PowerHalControllerBenchmarks_init(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.init(); } } static void BM_PowerHalControllerBenchmarks_initCached(benchmark::State& state) { PowerHalController controller; // First connection out of test. controller.init(); while (state.KeepRunning()) { controller.init(); } } static void BM_PowerHalControllerBenchmarks_setBoost(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.setBoost(Boost::INTERACTION, 0); } } static void BM_PowerHalControllerBenchmarks_setBoostCached(benchmark::State& state) { PowerHalController controller; // First call out of test, to cache supported boost. controller.setBoost(Boost::INTERACTION, 0); while (state.KeepRunning()) { controller.setBoost(Boost::INTERACTION, 0); } } static void BM_PowerHalControllerBenchmarks_setMode(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.setMode(Mode::INTERACTIVE, false); } } static void BM_PowerHalControllerBenchmarks_setModeCached(benchmark::State& state) { PowerHalController controller; // First call out of test, to cache supported mode. controller.setMode(Mode::INTERACTIVE, false); while (state.KeepRunning()) { controller.setMode(Mode::INTERACTIVE, false); } } BENCHMARK(BM_PowerHalControllerBenchmarks_init); BENCHMARK(BM_PowerHalControllerBenchmarks_initCached); BENCHMARK(BM_PowerHalControllerBenchmarks_setBoost); BENCHMARK(BM_PowerHalControllerBenchmarks_setBoostCached); BENCHMARK(BM_PowerHalControllerBenchmarks_setMode); BENCHMARK(BM_PowerHalControllerBenchmarks_setModeCached); Loading
services/powermanager/PowerHalWrapper.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -117,8 +117,7 @@ HalResult AidlHalWrapper::setBoost(Boost boost, int32_t durationMs) { bool isSupported = false; auto isSupportedRet = mHandle->isBoostSupported(boost, &isSupported); if (!isSupportedRet.isOk()) { ALOGV("Skipped setBoost %s because Power HAL is not available to check " "support", ALOGV("Skipped setBoost %s because Power HAL is not available to check support", toString(boost).c_str()); return HalResult::FAILED; } Loading Loading @@ -149,8 +148,7 @@ HalResult AidlHalWrapper::setMode(Mode mode, bool enabled) { bool isSupported = false; auto isSupportedRet = mHandle->isModeSupported(mode, &isSupported); if (!isSupportedRet.isOk()) { ALOGV("Skipped setMode %s because Power HAL is not available to check " "support", ALOGV("Skipped setMode %s because Power HAL is not available to check support", toString(mode).c_str()); return HalResult::FAILED; } Loading
services/powermanager/benchmarks/Android.bp 0 → 100644 +39 −0 Original line number Diff line number Diff line // Copyright (C) 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_benchmark { name: "libpowermanager_benchmarks", srcs: [ "main.cpp", "PowerHalAidlBenchmarks.cpp", "PowerHalControllerBenchmarks.cpp", "PowerHalHidlBenchmarks.cpp", ], shared_libs: [ "libbase", "libbinder", "libhidlbase", "liblog", "libpowermanager", "libutils", "android.hardware.power@1.0", "android.hardware.power@1.1", "android.hardware.power-cpp", ], cflags: [ "-Wall", "-Werror", "-Wextra", ], }
services/powermanager/benchmarks/AndroidTest.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 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. --> <configuration description="Config for libpowermanager benchmarks"> <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer"> <option name="cleanup" value="true" /> <option name="push" value="libpowermanager_benchmarks->/data/benchmarktest/benchmark" /> </target_preparer> <option name="test-suite-tag" value="apct" /> <option name="test-suite-tag" value="apct-metric-instrumentation" /> <test class="com.android.tradefed.testtype.GoogleBenchmarkTest" > <option name="native-benchmark-device-path" value="/data/benchmarktest" /> <option name="benchmark-module-name" value="benchmark" /> </test> </configuration>
services/powermanager/benchmarks/PowerHalAidlBenchmarks.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright (C) 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. */ #define LOG_TAG "PowerHalAidlBenchmarks" #include <android/hardware/power/Boost.h> #include <android/hardware/power/IPower.h> #include <android/hardware/power/Mode.h> #include <benchmark/benchmark.h> #include <binder/IServiceManager.h> using android::hardware::power::Boost; using android::hardware::power::IPower; using android::hardware::power::Mode; using namespace android; template <class R, class... Args0, class... Args1> static void runBenchmark(benchmark::State& state, R (IPower::*fn)(Args0...), Args1&&... args1) { sp<IPower> hal = waitForVintfService<IPower>(); if (hal == nullptr) { ALOGI("Power HAL AIDL not available, skipping test..."); return; } while (state.KeepRunning()) { (*hal.*fn)(std::forward<Args1>(args1)...); } } static void BM_PowerHalAidlBenchmarks_isBoostSupported(benchmark::State& state) { bool isSupported; runBenchmark(state, &IPower::isBoostSupported, Boost::INTERACTION, &isSupported); } static void BM_PowerHalAidlBenchmarks_isModeSupported(benchmark::State& state) { bool isSupported; runBenchmark(state, &IPower::isModeSupported, Mode::INTERACTIVE, &isSupported); } static void BM_PowerHalAidlBenchmarks_setBoost(benchmark::State& state) { runBenchmark(state, &IPower::setBoost, Boost::INTERACTION, 0); } static void BM_PowerHalAidlBenchmarks_setMode(benchmark::State& state) { runBenchmark(state, &IPower::setMode, Mode::INTERACTIVE, false); } BENCHMARK(BM_PowerHalAidlBenchmarks_isBoostSupported); BENCHMARK(BM_PowerHalAidlBenchmarks_isModeSupported); BENCHMARK(BM_PowerHalAidlBenchmarks_setBoost); BENCHMARK(BM_PowerHalAidlBenchmarks_setMode);
services/powermanager/benchmarks/PowerHalControllerBenchmarks.cpp 0 → 100644 +88 −0 Original line number Diff line number Diff line /* * Copyright (C) 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. */ #define LOG_TAG "PowerHalControllerBenchmarks" #include <android/hardware/power/Boost.h> #include <android/hardware/power/Mode.h> #include <benchmark/benchmark.h> #include <powermanager/PowerHalController.h> using android::hardware::power::Boost; using android::hardware::power::Mode; using android::power::PowerHalController; using namespace android; static void BM_PowerHalControllerBenchmarks_init(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.init(); } } static void BM_PowerHalControllerBenchmarks_initCached(benchmark::State& state) { PowerHalController controller; // First connection out of test. controller.init(); while (state.KeepRunning()) { controller.init(); } } static void BM_PowerHalControllerBenchmarks_setBoost(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.setBoost(Boost::INTERACTION, 0); } } static void BM_PowerHalControllerBenchmarks_setBoostCached(benchmark::State& state) { PowerHalController controller; // First call out of test, to cache supported boost. controller.setBoost(Boost::INTERACTION, 0); while (state.KeepRunning()) { controller.setBoost(Boost::INTERACTION, 0); } } static void BM_PowerHalControllerBenchmarks_setMode(benchmark::State& state) { while (state.KeepRunning()) { PowerHalController controller; controller.setMode(Mode::INTERACTIVE, false); } } static void BM_PowerHalControllerBenchmarks_setModeCached(benchmark::State& state) { PowerHalController controller; // First call out of test, to cache supported mode. controller.setMode(Mode::INTERACTIVE, false); while (state.KeepRunning()) { controller.setMode(Mode::INTERACTIVE, false); } } BENCHMARK(BM_PowerHalControllerBenchmarks_init); BENCHMARK(BM_PowerHalControllerBenchmarks_initCached); BENCHMARK(BM_PowerHalControllerBenchmarks_setBoost); BENCHMARK(BM_PowerHalControllerBenchmarks_setBoostCached); BENCHMARK(BM_PowerHalControllerBenchmarks_setMode); BENCHMARK(BM_PowerHalControllerBenchmarks_setModeCached);