Skip to content

Conversation

@Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua commented Oct 7, 2025

Problem

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#reduced_time_precision

the precision of Date.now() might get rounded depending on browser settings. In Firefox, the privacy.reduceTimerPrecision preference is enabled by default and defaults to 2ms. You can also enable privacy.resistFingerprinting, in which case the precision will be 100ms or the value of privacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.

For example, with reduced time precision, the result of Date.now() will always be a multiple of 2, or a multiple of 100 (or privacy.resistFingerprinting.reduceTimerPrecision.microseconds) with privacy.resistFingerprinting enabled.

Solution

use performance.now()

basically revert changes made in #2323 to use Date.now() instead of performance.now()

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Will-ShaoHua Will-ShaoHua requested a review from a team as a code owner October 7, 2025 22:47
@Will-ShaoHua Will-ShaoHua changed the title fix: improve inline completion api latency precision fix: improve inline completion api latency measurement precision Oct 7, 2025
@Will-ShaoHua Will-ShaoHua marked this pull request as draft October 7, 2025 22:50
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.87%. Comparing base (a908195) to head (62d8c1a).

Files with missing lines Patch % Lines
...p-codewhisperer/src/shared/codeWhispererService.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2406   +/-   ##
=======================================
  Coverage   61.87%   61.87%           
=======================================
  Files         261      261           
  Lines       58505    58505           
  Branches     3672     3672           
=======================================
  Hits        36199    36199           
  Misses      22235    22235           
  Partials       71       71           
Flag Coverage Δ
unittests 61.87% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@Will-ShaoHua Will-ShaoHua marked this pull request as ready for review October 7, 2025 23:28
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.

2 participants