How Firefox Measures Approximate Power in Milliwatts

This article explains the technical mechanisms the Firefox Web Browser uses to estimate power consumption in milliwatts (mW) during performance profiling. It covers the hardware sensors, operating system APIs, and mathematical calculations Firefox utilizes across Windows, macOS, and Linux to translate raw energy data into actionable power metrics for web developers.

From Energy Counters to Milliwatts

Computer hardware does not typically report instantaneous power draw in watts directly to software. Instead, modern processors track cumulative energy consumption over time—usually measured in Joules or watt-hours.

To display power in milliwatts (mW), the Firefox Profiler samples these hardware energy counters at regular intervals (typically every few milliseconds). Firefox takes the difference in energy between two samples, normalizes that value into picowatt-hours (pWh), and divides it by the time elapsed between the samples. Because power is the rate of energy transfer over time, this calculation yields the average power in milliwatts for that specific timeframe.

Hardware-Level Estimation

Firefox relies on internal processor modeling rather than physical inline power meters.

  • Intel and AMD Processors: These chips use an interface called Running Average Power Limit (RAPL). RAPL estimates energy usage based on a complex mathematical model that factors in CPU frequency, voltage, temperature, and instruction activity.
  • Apple Silicon: Apple's M-series chips use proprietary onboard sensors and performance counters managed by the System Management Controller (SMC) to track energy usage across CPU, GPU, and Neural Engine cores.

Operating System APIs

Because a web browser cannot bypass the operating system to read hardware registers directly, Firefox queries OS-specific APIs to gather energy data.

Windows On Windows 11 (and newer builds of Windows 10), Firefox uses the Energy Metering Interface (EMI). EMI exposes hardware RAPL counters to user-space applications. Through EMI, Firefox reads the total energy consumed by the CPU package, cores, and integrated graphics, converting the reported picowatt-hours into milliwatts.

macOS On macOS, Firefox utilizes the proc_pid_rusage system call.

  • On Apple Silicon: The operating system attributes energy usage directly to individual processes. Firefox requests the energy data for its own specific process IDs (main process, content processes, GPU process), resulting in highly accurate per-tab or per-process power profiling.
  • On Intel Macs: The API returns system-wide processor energy usage in nanojoules, which Firefox converts to milliwatts.

Linux On Linux, Firefox accesses RAPL counters through the kernel's perf_event_open system call or by reading files directly from the powercap sysfs interface (/sys/class/powercap/intel-rapl/). Due to security restrictions regarding side-channel attacks, reading these counters on Linux requires the user to grant elevated permissions before profiling.

Why the Measurement is Approximate

Firefox characterizes these measurements as "approximate" due to several hardware and OS limitations:

  1. System-Wide vs. Process-Specific Data: On Windows, Linux, and Intel-based Macs, RAPL only reports the power usage of the entire CPU package. If a background application spikes the CPU while Firefox is profiling, that energy is included in the Firefox Profiler's power tracks. Only Apple Silicon currently isolates power data strictly to the Firefox process.
  2. Unmeasured Components: The power values mostly reflect CPU, integrated GPU, and sometimes RAM usage. They do not account for display backlight brightness, discrete GPUs, cooling fans, or network card activity (such as Wi-Fi antennas), all of which drain battery life.
  3. Model-Based Hardware: Because mechanisms like Intel RAPL calculate energy using activity algorithms rather than physical current sensors, the baseline numbers provided to the OS are inherently estimates.