1. Introduction
This section is non-normative.
There has always been developer interest for adapting web content, based on how powerful the user device is. E.g., video-conferencing applications or video games may use this information to decide if advanced video effects can be rendered; all types of applications may use it to decide whether to attempt running AI tasks locally or delegate to the server, etc.
In particular, web applications may want to use performance information to:
-
Control non-essential tasks and requests; e.g., allow or block 3rd party scripts, use or avoid heavy libraries.
-
Adjust the complexity of web content; e.g., the resolution and format for images and video, the compression level for uploading data, enable or disable computationally heavy operations such as animations, improve resource management (lazy loading, prefetching, prerendering).
-
Improve real user monitoring; e.g., better understand if users have faster or slower devices, focus development effort more appropriately.
-
Run computations on the client side vs. on the server side; e.g., use server-side rendering, run AI applications and LLMs on the client side.
-
Select ads that are better suited for the user device.
2. CPU Performance
Modern computing devices often integrate multiple, heterogeneous processing units, differing in their nature and capabilities. The Central Processing Unit (CPU) is the central component in every computing device. Modern computing devices contain a number of integrated circuits (multi-core processors), each containing a number of physical cores that operate as independent CPUs. Furthermore, technologies for simultaneous multi-threading (or hyper-threading) allow physical cores to handle multiple instruction threads, thus appearing as multiple separate logical cores to the operating system.
Beyond CPU, modern computers may comprise other types of processing units, such as:
-
Graphics Processing Units (GPU) for handling complex graphics, video, and computationally intensive tasks in parallel, like scientific simulations and AI training;
-
Neural Processing Units (NPU) or Tensor Processing Units (TPU) for improving performance in AI and machine learning tasks;
-
Digital Signal Processors (DSP) for optimizing the real-time processing of signals;
-
Field-Programmable Gate Arrays (FPGA) for optimizing specific tasks via custom accelerators implemented with reconfigurable, programmable hardware, etc.
This specification currently addresses the Central Processing Unit only, aiming to expose a measure of its performance to web applications. Future versions of this specification may also address other types of processing units.
We will use the term CPU for the collection of central processing units that are contained in a computing device. We will use the term core to refer to a CPU part that can execute instruction threads, physical or logical, as reported by the operating system.
We will use the term performance to refer to how fast the CPU is perceived to be, from the point of view of a web application. A fast CPU handles tasks quicker, e.g., leading to faster application loading, better multitasking, smoother gaming, etc.
3. Performance Tiers
The CPU Performance API classifies user devices according to their CPU performance in a small number of performance tiers. Each performance tier is represented by a small positive integer number. Higher values correspond to higher performance tiers, i.e., to more powerful user devices.
There are four distinct performance tiers, numbered 1–4. Applications using the API should handle additional tiers (numbered 5 and above) which are likely to be added in the future as devices improve over time.
The special value 0 (zero) corresponds to an unknown performance tier, returned in case the API’s implementation is unable to classify the user device.
3.1. Computing Performance Tier Value
-
Let cores be the number of logical cores of the CPU as reported by the operating system, or null if the operating system does not report a core count.
-
If cores is null or 0, return 0.
-
If cores is 1, return 1.
-
Let manufacturer and model be the name of the CPU manufacturer and the model of the CPU, as reported by the operating system, or null if the operating system does not report CPU information.
-
If cores is less than or equal to 4:
i. If manufacturer is "AMD":
-
If cores is 2 and model matches any of the K8, K10, Llano, or mobile Trinity microarchitectures, return 1.
-
If cores is 2 and model matches any of the Bobcat or Jaguar microarchitectures, return 1.
-
If cores is 2 and model matches any of the A4-9120C or A4-9120e models, return 1.
-
If cores is 4 and model matches the Ryzen brand, excluding dual-core models with Simultaneous Multithreading (SMT), return 3.
ii. If manufacturer is "Intel":
-
If cores is greater than or equal to 2 and model matches any of the Bonnell or Saltwell microarchitectures, return 1.
-
If cores is greater than or equal to 2 and model matches any of the Silvermont or Airmont microarchitectures, return 1.
-
If cores is 2 and model matches the Goldmont microarchitecture, return 1.
-
If cores is 2 and model matches any of the Merom or Penryn microarchitectures, return 1.
-
If cores is 2 and model matches any of the Nehalem or Westmere microarchitectures, return 1.
-
If cores is 2 and model matches any of the mobile Sandy Bridge or mobile Ivy Bridge microarchitectures, return 1.
-
If cores is 4 and model matches the Gracemont microarchitecture, return 3.
iii. If cores is less than or equal to 2, return 1.
iv. Return 2.
-
-
If cores is less than or equal to 10:
i. If manufacturer is "Apple":
-
If cores is greater than or equal to 8 and model matches the M-series, return 4.
-
If cores is greater than or equal to 8 and model matches the Core Ultra brand, return 4.
-
-
Return 4.
NOTE: A JavaScript reference implementation of this algorithm (derived from the implementation in the Chromium browser engine) is available in the cpu-performance repository, along with an interactive demo page that illustrates how the algorithm classifies a wide range of real-world devices.
The algorithm above was designed in such a way to adhere to the following rules. Future updates to the specification should also adhere to the same rules:
-
Consistency: The mapping of devices to performance tiers should reflect the CPU performance that can be measured with specific benchmarks, ideally using programming tools provided by a browser (JavaScript, WebAssembly, etc.) and measured in ideal conditions. More powerful devices should not be classified in lower performance tiers than less powerful devices.
-
Reproducibility: An implementation should always report the same performance tier for the same user device. In particular:
-
The reported performance tier should not depend on the user device’s current load or utilization; and
-
Implementations should not redefine tiers; that is, tier 4 devices should not be reclassified as tier 3 to accommodate newer, higher-powered devices as technology improves. Instead, a new tier 5 will be added to this specification for those newer devices, when the need arises, and then a tier 6 and so on.
NOTE: The intention of this rule is not to make it impossible to fix classification mistakes in implementations of this API. Such mistakes will inevitably have to be fixed, both in the current specification and/or in implementations. Rather, the intention of the rule is not to reclassify CPU models with new technology emerging, so as not to break the behavior of obsolete machines running obsolete applications.
-
-
User privacy: To avoid user fingerprinting, implementations should ensure that a fairly large number of user devices fall into each performance tier (see also § 5 Security and Privacy Considerations). In particular, each performance tier should contain many distinct CPU models, and the special value 0 should be returned only when the implementation cannot obtain information about the number of cores from the operating system.
4. Javascript API
[
SecureContext ,
Exposed =Window
] partial interface Navigator {
readonly attribute unsigned short cpuPerformance ;
};
cpuPerformance getter
steps are:
-
Let tier be the result of computing the performance tier of the device’s CPU, as described in § 3.1 Computing Performance Tier Value.
-
Assert: 0 ≤ tier ≤ 4.
-
Return tier.
5. Security and Privacy Considerations
The CPU Performance API will only be available to HTTPS secure contexts.
To reduce fingerprinting risk, the CPU Performance API does not reveal CPU characteristics directly. The reported value is a small integer number that represents the performance tier corresponding to the CPU. For each possible value (tier), implementations should ensure that a fairly large number of computing devices existing on the internet at any given time, both as an absolute number and as distinct CPU models, are classified as having this performance tier. In particular, the intention of this specification is that each performance tier should contain no less than 10% of the existing CPU models, and no less than 10% of the existing user devices at any given time.
See also the TAG Security/Privacy Questionnaire.
6. Example
This section is non-normative.
A video conferencing application could interpret the four performance tiers as follows. This interpretation is application specific and, even then, it may have to be updated in the future if the application itself is updated and its hardware requirements change.
-
1: devices that are practically unusable for video calls;
-
2: underpowered devices but still adequately suited for video calls;
-
3: devices that can comfortably accommodate video calls; and
-
4: devices that can run even the most demanding scenarios and have performance to spare for multitasking.
Such an application could use the value of navigator.cpuPerformance
for pre-selecting a number of features that are best supported by the
user device’s performance tier.
function getPresetFeatures() { switch ( navigator. cpuPerformance) { case 1 : return { videoQuality: 'QVGA' , frameRate: 15 , effects: [], }; case 2 : return { videoQuality: 'VGA' , frameRate: 15 , effects: [ 'voice-detection' , 'animated-reactions' ], }; case 3 : return { videoQuality: '720p' , frameRate: 30 , effects: [ 'voice-detection' , 'animated-reactions' , 'noise-reduction' ], }; case 4 : case 0 : // Assuming high performance settings for unknown devices default : // and for performance tiers higher than 4. return { videoQuality: '1080p' , frameRate: 30 , effects: [ 'voice-detection' , 'animated-reactions' , 'noise-reduction' , 'virtual-background' ], }; } }
7. Acknowledgements
Many thanks for valuable feedback and advice from: Dominic Farolino, Deepti Gandluri, Reilly Grant, Tomas Gunnarsson, Markus Handell, Michael Lippautz, Thomas Nattestad, Nicola Tommasi, Guido Urdaneta, Måns Vestin, and Chen Xing.
Thanks to the W3C Web Performance Working Group (WebPerf) and especially Yoav Weiss.