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

[NoQA] fix: timing measurements are inaccurate #48654

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/libs/actions/Timing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let timestampData: Record<string, TimestampData> = {};
* @param shouldUseFirebase - adds an additional trace in Firebase
*/
function start(eventName: string, shouldUseFirebase = true) {
timestampData[eventName] = {startTime: Date.now(), shouldUseFirebase};
timestampData[eventName] = {startTime: performance.now(), shouldUseFirebase};

if (!shouldUseFirebase) {
return;
Expand All @@ -42,13 +42,13 @@ function end(eventName: string, secondaryName = '', maxExecutionTime = 0) {
}

const {startTime, shouldUseFirebase} = timestampData[eventName];
Environment.getEnvironment().then((envName) => {
const eventTime = Date.now() - startTime;

if (shouldUseFirebase) {
Firebase.stopTrace(eventName);
}
if (shouldUseFirebase) {
Firebase.stopTrace(eventName);
}

const eventTime = performance.now() - startTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: Is it better not to count Firebase.startTrace(eventName) and Firebase.stopTrace(eventName) in the eventTime? Though both of them look lightweight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, good point - for Firebase.startTrace its already the case, I changed it to be also the case for stopTrace!

Copy link
Contributor

Choose a reason for hiding this comment

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

for Firebase.startTrace its already the case

Hmm, but we should get startTime after Firebase.startTrace right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that makes sense as well! I think now we got it 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah sorry i think i committed to the wrong branch, one sec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, now

Environment.getEnvironment().then((envName) => {
const baseEventName = `${envName}.new.expensify.${eventName}`;
const grafanaEventName = secondaryName ? `${baseEventName}.${secondaryName}` : baseEventName;

Expand Down
Loading