/* * Copyright 2019 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. */ #include #include #include #include using android::IBinder; using android::sp; using android::system::suspend::internal::ISuspendControlServiceInternal; using android::system::suspend::internal::WakeLockInfo; using android::system::suspend::V1_0::ISystemSuspend; using android::system::suspend::V1_0::IWakeLock; using android::system::suspend::V1_0::WakeLockType; static void BM_acquireWakeLock(benchmark::State& state) { static sp suspendService = ISystemSuspend::getService(); while (state.KeepRunning()) { suspendService->acquireWakeLock(WakeLockType::PARTIAL, "BenchmarkWakeLock"); } } BENCHMARK(BM_acquireWakeLock); static void BM_getWakeLockStats(benchmark::State& state) { static sp controlInternal = android::defaultServiceManager()->getService(android::String16("suspend_control_internal")); static sp controlServiceInternal = android::interface_cast(controlInternal); while (state.KeepRunning()) { std::vector wlStats; controlServiceInternal->getWakeLockStats(&wlStats); } } BENCHMARK(BM_getWakeLockStats); BENCHMARK_MAIN();