diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /tools/profiler/core/PowerCounters.h | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/profiler/core/PowerCounters.h')
-rw-r--r-- | tools/profiler/core/PowerCounters.h | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/tools/profiler/core/PowerCounters.h b/tools/profiler/core/PowerCounters.h index 2fd8d5892c..df511e87ec 100644 --- a/tools/profiler/core/PowerCounters.h +++ b/tools/profiler/core/PowerCounters.h @@ -19,20 +19,57 @@ class ProcessPower; #if defined(GP_PLAT_amd64_darwin) class RAPL; #endif +#if defined(GP_PLAT_arm64_android) + +/* + * These declarations come from: + * https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/src/android_internal/power_stats.h;l=34-52;drc=1777bdef274bcfbccd4e6f8b6d00a1bac48a8645 + */ + +struct RailDescriptor { + // Index corresponding to the rail + uint32_t index; + // Name of the rail + char rail_name[64]; + // Name of the subsystem to which this rail belongs + char subsys_name[64]; + // Hardware sampling rate + uint32_t sampling_rate; +}; + +struct RailEnergyData { + // Index corresponding to RailDescriptor.index + uint32_t index; + // Time since device boot(CLOCK_BOOTTIME) in milli-seconds + uint64_t timestamp; + // Accumulated energy since device boot in microwatt-seconds (uWs) + uint64_t energy; +}; +bool GetRailEnergyData(RailEnergyData*, size_t* size_of_arr); +#endif class PowerCounters { public: -#if defined(_MSC_VER) || defined(GP_OS_darwin) || defined(GP_PLAT_amd64_linux) +#if defined(_MSC_VER) || defined(GP_OS_darwin) || \ + defined(GP_PLAT_amd64_linux) || defined(GP_PLAT_arm64_android) explicit PowerCounters(); +#else + explicit PowerCounters(){}; +#endif +#if defined(_MSC_VER) || defined(GP_PLAT_amd64_darwin) || \ + defined(GP_PLAT_arm64_android) ~PowerCounters(); +#else + ~PowerCounters() = default; +#endif +#if defined(_MSC_VER) || defined(GP_PLAT_amd64_darwin) || \ + defined(GP_PLAT_arm64_android) void Sample(); #else - explicit PowerCounters(){}; - ~PowerCounters(){}; void Sample(){}; #endif - using CountVector = mozilla::Vector<BaseProfilerCount*, 4>; + using CountVector = mozilla::Vector<mozilla::UniquePtr<BaseProfilerCount>, 4>; const CountVector& GetCounters() { return mCounters; } private: @@ -41,11 +78,14 @@ class PowerCounters { #if defined(_MSC_VER) mozilla::Vector<mozilla::UniquePtr<PowerMeterDevice>> mPowerMeterDevices; #endif -#if defined(GP_PLAT_arm64_darwin) - mozilla::UniquePtr<ProcessPower> mProcessPower; -#endif #if defined(GP_PLAT_amd64_darwin) - RAPL* mRapl; + mozilla::UniquePtr<RAPL> mRapl; +#endif +#if defined(GP_PLAT_arm64_android) + void* mLibperfettoModule = nullptr; + decltype(&GetRailEnergyData) mGetRailEnergyData = nullptr; + mozilla::Vector<RailDescriptor> mRailDescriptors; + mozilla::Vector<RailEnergyData> mRailEnergyData; #endif }; |