loading
Warning:
Chromium only, over HTTPS The Compute Pressure API ships in Chromium-based browsers. Firefox and Safari do not implement it.
Note:
Four states, not a number A precise load figure would be a timing side channel, so the API reports a coarse scale: nominal, fair, serious, critical. Treat serious as "shed optional work" - drop a video call's resolution, cut effect quality - and critical as "shed everything you can".

Support and sources

IsSupported / GetKnownSources

GetKnownSources lists what this browser can observe - ['cpu'] today. Worth reading before hard-coding a source, since observing an unknown one simply fails.

C#
@inject Bit.Butil.ComputePressure computePressure

var supported = await computePressure.IsSupported();
var sources = await computePressure.GetKnownSources();
Live sample
support output
Results will appear here when you interact with the samples.

Observe pressure

Observe

The callback fires when the state changes, not on a timer, so a machine sitting at 'nominal' costs nothing. Press the load button below to push this machine up the scale and watch the state follow.

C#
await using var observer = await computePressure.Observe(records =>
{
    foreach (var record in records)
    {
        // record.Source, record.State, record.Time
    }
}, source: "cpu", sampleIntervalMs: 1000);
Live sample
Source
Sample interval (ms, 0 = browser's choice)
pressure output
Results will appear here when you interact with the samples.

API reference

Member
Signature
Description
IsSupported
ValueTask<bool> IsSupported()
True when the runtime exposes PressureObserver. Returns default (false) during prerender/SSR instead of throwing.
GetKnownSources
ValueTask<string[]> GetKnownSources()
The pressure sources this browser can observe - ['cpu'] today.
Observe
ValueTask<ButilSubscription> Observe(Action<PressureRecord[]> handler, string source = 'cpu', int sampleIntervalMs = 0)
Starts observing a source. Dispose the subscription to stop.
DisposeAsync
ValueTask DisposeAsync()
Disconnects every observer this instance started and releases the JS callback reference.
InvokePressureRecords
void InvokePressureRecords(Guid id, PressureRecord[] records)
JSInvokable interop plumbing for pressure records - not intended for app code.
PressureRecord
class PressureRecord { string Source; string State; double Time; }
One sample: the source, one of nominal/fair/serious/critical, and the time on the performance.now() clock.
An unhandled error has occurred. Reload 🗙