Performance API
Pylenium's custom performance API to capture different metrics.
Syntax
Usage
The Performance class is where everything lives. It provides access to the following methods:
WebPerformance
The main method used to generate a WebPerformance object from the current web page. This is really all you need from this API and will be discussed in more detail further below in Metrics.
Calling this method too soon may yield NoneTypes because the browser hasn't generated them yet.
Time Origin
Return the timeOrigin precision value. This is the high-resolution timestamp of the start time of the performance measurement.
Navigation Timing
Return the PerformanceNavigationTiming W3 object as a Python object called NavigationTiming.
Paint Timing
Return the PerformancePaintTiming object as a Python object called PaintTiming.
Resources
Return a list of PerformanceResourceTiming objects as Python objects called [ResourceTiming].
Metrics
All of the timing objects include A LOT of data points, but many of them may not be useful.
If you want to see ALL the data points, take a look at the file in the GitHub Repo
This is why the WebPerformance object exists! It contains calculations for metrics that have been very useful when we talk about and measure web performance. After navigating to a website and capturing these metrics with py.performance.get()
, we can do whatever we want with them!
With a few lines of code, you have access to many valuable metrics:
Page Load Time
The time it takes for the page to load as experienced by the user.
Time to First Byte
The time it takes before the first byte of response is received from the server.
Time to First Contentful Paint
The time it takes for the majority of content to be fully rendered and consumable by the user.
Time to Interactive (TTI)
The time it takes for the layout to be stabilized and the page is responsive.
Number of Requests
The number of requests sent from start of navigation until end of page load.
Time to DOM Content Loaded
The time it takes for the DOM content to load.
Page Weight
The amount of bytes transferred for the page to be loaded.
Connection Time
The time taken to connect to the server.
Request Time
The time taken to send a request to the server and receive the response.
Fetch Time
The time to complete the document fetch (including accessing any caches, etc.).
Examples
Store the entire WebPerformance object in a variable, then convert it to a Dictionary to log it.
Store a single data point in a variable and test against it.
Last updated