• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <aidl/android/hardware/power/WorkDuration.h>
20 
21 #include <chrono>
22 
23 #include "PhysicalQuantityTypes.h"
24 
25 using aidl::android::hardware::power::WorkDuration;
26 
27 namespace aidl {
28 namespace google {
29 namespace hardware {
30 namespace power {
31 namespace impl {
32 namespace pixel {
33 
gpu_time_attribution(std::chrono::nanoseconds total,std::chrono::nanoseconds gpu)34 inline double gpu_time_attribution(std::chrono::nanoseconds total, std::chrono::nanoseconds gpu) {
35     using std::literals::chrono_literals::operator""ns;
36     if (total == 0ns) {
37         return 0.0;
38     }
39     return std::chrono::duration_cast<std::chrono::duration<double, std::nano>>(gpu) / total;
40 }
41 
42 Cycles calculate_capacity(WorkDuration observation, std::chrono::nanoseconds target,
43                           Frequency gpu_frequency);
44 
45 }  // namespace pixel
46 }  // namespace impl
47 }  // namespace power
48 }  // namespace hardware
49 }  // namespace google
50 }  // namespace aidl
51