Micheal Toru
Micheal Toru

Reputation: 442

How to get in Chrome Extension CPU usage in percentage

i can get the CPU usage by using chrome.processes (which only works on Chrome Dev), this API retrieve the usage not in percentage.

I get long numbers like: 1.5612728395 & 121.5613212 & 24.215326622 as CPU usage.

What do they mean? They are not percentage. How can i convert them to percentage usage?

Upvotes: 1

Views: 350

Answers (1)

helb
helb

Reputation: 3234

They are percentages, but the number is calculated per CPU core, so more than 100 % (121.56 % in your case) means that it's using more than one core (multi-threaded process).

From the docs:

The most recent measurement of the process’s CPU usage, expressed as the percentage of a single CPU core used in total, by all of the process’s threads. This gives a value from zero to CpuInfo.numOfProcessors*100, which can exceed 100% in multi-threaded processes. Only available when receiving the object as part of a callback from onUpdated or onUpdatedWithMemory.

So if you have eg. 4 cores (or 2 with Hyper-threading), the maximum is 400.

Upvotes: 2

Related Questions