Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

add custom api for adding ttfmp from fragments #214

Merged
merged 1 commit into from
Jan 11, 2018

Conversation

vigneshshanmugam
Copy link
Collaborator

@vigneshshanmugam vigneshshanmugam commented Jan 11, 2018

Why?

  • The previous API for adding performance entries to the page is pretty neat and already helps fragments to add custom timing information at every point of the render phase. But it lacks the uniformity and it will be pretty hard to use it for monitoring or any other purpose since the naming is quite different on every page.

  • Meaningful paint is different for each page and its hard to measure from tailor since tailor has no context of elements being rendered from fragments. Its best to keep the logic in fragments.

Solution

The current API is just a proxy to the old Pipe.addPerfEntry

Pipe.addTTFMPEntry(2000);

Pipe.getEntries()
// [{
    duration: 2000
    ​​entryType: "tailor"
    name: "ttfmp"
    startTime: <value based on current time>
}]
  • This API will be used only when primary fragments decide that the page is meaningful and the import part of the page is painted. It can be a Hero element that decides the meaningful paint of the page

  • Calling the API multiple times results in duplicate entries added to the Performance Entry. This is to keep in sync with PerformanceEntry Object

Future

  • We could use Hero Element Timing API to mark the important elements that determine the meaningful paint of the page.

@codecov
Copy link

codecov bot commented Jan 11, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@effbe16). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             master   #214   +/-   ##
=======================================
  Coverage          ?    99%           
=======================================
  Files             ?     15           
  Lines             ?    603           
  Branches          ?    112           
=======================================
  Hits              ?    597           
  Misses            ?      6           
  Partials          ?      0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update effbe16...368dbdc. Read the comment docs.

// Unique API that allows fragments to specify the
// time to first meaningul paint of the page
function addTTFMPEntry(duration) {
addPerfEntry('ttfmp', duration);
Copy link
Collaborator Author

@vigneshshanmugam vigneshshanmugam Jan 11, 2018

Choose a reason for hiding this comment

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

just keeping it as ttfmp to avoid the name collision in future once first-meaningful-paint is added to Paint Timing

@ruiaraujo
Copy link
Contributor

👍

1 similar comment
@vigneshshanmugam
Copy link
Collaborator Author

👍

@vigneshshanmugam vigneshshanmugam merged commit 31ced26 into master Jan 11, 2018
@vigneshshanmugam vigneshshanmugam deleted the custom-perf-api branch January 11, 2018 12:15
@@ -203,6 +211,7 @@
onAfterInit: assignHook('onAfterInit'),
onDone: assignHook('onDone'),
addPerfEntry: addPerfEntry,
addTTFMPEntry: addTTFMPEntry,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think addPerfEntry.bind(null, 'ttfmp') is shorter than the current implementation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bind is slow in older versions of v8 (older browsers might suffer from this). Thats why i went for explicit function. But, its just one time call so shouldn't matter much.

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

Successfully merging this pull request may close these issues.

3 participants