Skip to content

Use base 10 when calculating memory#5810

Merged
fatadel merged 3 commits intofirefox-devtools:mainfrom
fatadel:refine-format-bytes-5485
Feb 6, 2026
Merged

Use base 10 when calculating memory#5810
fatadel merged 3 commits intofirefox-devtools:mainfrom
fatadel:refine-format-bytes-5485

Conversation

@fatadel
Copy link
Contributor

@fatadel fatadel commented Feb 4, 2026

Closes #5485.

I hope I correctly understood the issue and the following intentions. Also, there were 2 different opinions when we were discussing the issue:

  1. Use base 10 numbers everywhere;
  2. Selectively use base 10 vs base 2 numbers;

I agree with opinion 1, as it makes things easier and consistent imo. But feel to propose other solutions.

Example profile: before / after.

@fatadel fatadel requested review from canova and mstange February 4, 2026 11:48
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.57%. Comparing base (0693702) to head (dd02b5e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5810   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files         320      320           
  Lines       31448    31448           
  Branches     8570     8656   +86     
=======================================
  Hits        26911    26911           
  Misses       4106     4106           
  Partials      431      431           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@canova
Copy link
Member

canova commented Feb 5, 2026

Hey @fatadel, thanks for the PR! The example profile you shared is a regular sampling profile. Could you capture and share a memory profile using for example the "Native Allocation" feature in the about:profiling?

@fatadel
Copy link
Contributor Author

fatadel commented Feb 5, 2026

Thanks for the hint, @canova! Updated the links.

@canova canova changed the title use base 10 when calcualting memory Use base 10 when calculating memory Feb 6, 2026
Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Btw, I updated the title to fix the typo and also changed the capitalization.


it('can return values with kilobyte precision', () => {
expect(formatGigaBytes(1234567890, 3, 2, 1024)).toBe('1GB 153MB 385KB');
expect(formatGigaBytes(1234567890, 3, 2, 1024)).toBe('1GB 234MB 568KB');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(formatGigaBytes(1234567890, 3, 2, 1024)).toBe('1GB 234MB 568KB');
expect(formatGigaBytes(1234567890, 3, 2, 1000)).toBe('1GB 234MB 568KB');

nit: it would be good to change these precision values to 10 based too. (here and below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review and for the nit, @canova! I've incorporated it, will merge now.

@fatadel fatadel merged commit 66ea79f into firefox-devtools:main Feb 6, 2026
21 checks passed
@fatadel fatadel deleted the refine-format-bytes-5485 branch February 6, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatBytes is ambiguous as it displays mebibyte (MiB) numbers but the label suggests megabytes (MB)

2 participants