Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cumulativeCPUUsage to AppMetrics and CPUUsage #41819

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rcombs
Copy link

@rcombs rcombs commented Apr 10, 2024

Description of Change

This allows apps to measure their CPU usage over any given period without worrying about other calls affecting the output, as they would with percentCPUUsage.

Checklist

Haven't run the tests because I couldn't get the build process to cooperate locally, but this worked fine and returned results in line with expectations on a CI build I ran.

Release Notes

Notes: Added cumulativeCPUUsage to AppMetrics and CPUUsage

Copy link

welcome bot commented Apr 10, 2024

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Apr 10, 2024
@codebytere codebytere added the semver/minor backwards-compatible functionality label Apr 10, 2024
@codebytere codebytere requested a review from a team April 10, 2024 09:10
@codebytere
Copy link
Member

hey @rcombs - thanks for this! We'll try to take a look as soon as we can. Could you please address the lint issue here in the meantime?

@rcombs rcombs force-pushed the cumulativeCPUUsage branch 4 times, most recently from dfe3d4e to 80c045f Compare April 11, 2024 05:16
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@ckerr
Copy link
Member

ckerr commented Apr 16, 2024

API LGTM

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@codebytere
Copy link
Member

@rcombs can you rebase and fix conflicts?

This allows apps to measure their CPU usage over any given period
without worrying about other calls affecting the output,
as they would with `percentCPUUsage`.
Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcombs if you can fix the build failures we should be able to get this merged in.

Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

cpu_dict.Set("percentCPUUsage", usage / processor_count);
// Default usage percentage to 0 for compatibility
double usagePercent = 0;
if (auto usage = process_metric.second->metrics->GetCumulativeCPUUsage()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use the base::TimeDelta value. A gin converter (see time_converter.cc) might need to be added for the JS binding, if it's not set as a primitive type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants