Google DevTools Explanation

Evaluating network performance

The Network panel records information about each network operation in your application, including detailed timing data, HTTP request and response headers, cookies, WebSocket data, and more. The Network panel helps you answer questions about the network performance of your web application, such as:

  • Which resource had the slowest time to first byte?
  • Which resources took the longest time to load (duration)?
  • Who initiated a particular network request?
  • How much time was spent in the various network phases for a particular resource?

About the Resource Timing API

The Network panel uses the Resource Timing API, a JavaScript API that provides detailed network timing data for each loaded resource. For example, the API can tell you precisely when the HTTP request for an image started, and when the image‘s final byte was received. The following illustration shows the network timing data points that the Resource Timing API provides.

The API is available to any web page, not just DevTools. In Chrome, it‘s exposed as methods on the globalwindow.performance object. The performance.getEntries() method returns an array of "resource timing objects", one for each requested resource on the page.

Try this: open the JavaScript console on the current page, enter the following at the prompt, and hit Return:

window.performance.getEntries()[0]

This evaluates the first element in the array of resource timing objects and displays its properties in the console, as shown below.

Each timestamp is in microseconds, following the High ResolutionTime specification. This API is available inChrome as the window.performance.now() method.

Network panel overview

The Network panel automatically records all network activity while DevTools is open. The first time you open the panel it may be empty. Reload the page to start recording, or simply wait for network activity to occur in your application.

Each requested resource is added as a row to the Network table, which contains the columns listed below. Note the following about the Network table:

  • Not all columns listed below are visible by default; you can easily show or hide columns.
  • Some columns contain a primary field and a secondary field (Time and Latency, for example). When viewing the Network table with large resource rows both fields are shown; when using small resource rows only the primary field is shown.
  • You can sort the table by a column‘s value by clicking the column header. The the Timeline columnbehaves a bit differently: clicking its column header displays a menu of additional sort fields. See Waterfall view and Sorting and filtering for more information.
Name and Path
The name and URL path of the resource, respectively.
Method
The HTTP method used for the request. For example: GET or POST.
Status and Text
The HTTP status code and text message.
Domain
The domain of the resource request.
Type
The MIME type of the requested resource.
Initiator
The object or process that initiated the request. It can have one of the following values:

Parser
Chrome‘s HTML parser initiated the request.
Redirect
A HTTP redirect initiated the request.
Script
A script initiated the request.
Other
Some other process or action initiated the request, such as the user navigating to a page via a link, or by entering a URL in the address bar.
Cookies
The number of cookies transferred in the request. These correspond to the cookies shown in the Cookies tab when viewing details for a given resource.
Set-Cookies
The number of cookies set in the HTTP request.
Size and Content
Size is the combined size of the response headers (usually a few hundred bytes) plus the response body, as delivered by the server. Content is the size of the resource‘s decoded content. If the resource was loaded from the browser‘s cache rather than over the network, this field will contain the text (from cache).
Time and Latency
Time is total duration, from the start of the request to the receipt of the final byte in the response. Latency is the time to load the first byte in the response.
Timeline
The Timeline column displays a visual waterfall of all network requests. Clicking the header of this column reveals a menu of additional sorting fields.

Preserving the network log upon navigation

By default, the current network record log is discarded when you navigate to another page, or reload the current page. To preserve the recording log in these scenarios, click the black Preserve log upon navigationbutton  at the bottom of the Network panel; new records are appended to the bottom of the table. Click the same button again (now red ) to disable log preservation.

Sorting and filtering

By default, resources in the Network table are sorted by the start time of each request (the network "waterfall"). You can sort the table by another column value by clicking the column header. Click the header again to change the sort order (ascending or descending).

The Timeline column is unique from the others in that, when clicked, it displays a menu of additional sort fields.

The menu contains the following sorting options:

  • Timeline — Sorts by the start time of each network request. This is the default sort, and is the same as sorting by the Start Time option).
  • Start Time — Sorts by the start time of each network request (same as sorting by the Timeline option).
  • Response Time — Sorts by each request‘s response time.
  • End Time — Sorts by the time when each request completed.
  • Duration — Sorts by the total time of each request.
  • Latency — Sorts by the time between the start of the request and the beginning of the response (also known as the "time to first byte").

To filter the Network table to only show certain types of resources, click one of the content types along the bottom of the panel: DocumentsStylesheetsImagesScriptsXHRFontsWebSockets, and Other. In the following screenshot only CSS resources are shown. To view all content types, click the All filter button.

Advanced filtering

In addition to resource type filtering, you can narrow down resources by filter queries. For example, to find all resources which have a status code of 200, you can enter the query StatusCode:200 in the filter input field.

Take note of the following behaviour: A filter query includes a type (StatusCode) and value (200). A filter query is case insensitive, so you can type uppercase or lowercase. The filter type gives you autocomplete suggestions. Use the arrows keys to form a selection and press Tab to select it. The filter value has autocomplete which shows you values present in the current network recording. Quickly preview the results of your query, use the Up / Down arrow keys to cycle through the autocomplete suggestions. The results appear immediately even you do not press enter or tab to complete the selection. To negate a filter query, prepend the query with a dash (-), for example -StatusCode:200.

Available filter types:

domain
The domain portion from the URL of the resource. E.g. www.google-analytics.com.
has-response-header
Checks the resource has a response header, regardless of the value. E.g.Access-Control-Allow-Origin.
is
Shows requests running at the current point in time. Current available value:running
larger-than
Shows requests with a transfer size larger than the specified amount. Units assumed in bytes, but kilobyte (k) & megabyte (m) units also allowed: E.g.larger-than:50larger-than:150klarger-than:2m
method
The HTTP method used. E.g. GET.
mime-type
Also known as Content-type - the identifier for the type of resource. E.g.text/html.
scheme
The scheme portion in a URL. E.g. https.
set-cookie-name
The name of the cookie as set by the server. E.g. loggedIn (assuming a cookie like loggedIn=true).
set-cookie-value
The value of the cookie set by the server. E.g. true (assuming a cookie likeloggedIn=true).
set-cookie-domain
The domain of the cookie as set by the server. E.g. foo.com (assuming a cookie like loggedIn=true; Domain=foo.com; Path=/; Expires=Wed, 13 Jan 2021 22:23:01 GMT; HttpOnly).
status-code
The status code in the HTTP response. E.g. 200.

To use a query shown in the above list, construct it in the format of: <Filter Type>:<Description>. You will almost always want to use the autocomplete suggestions which ensures your query is valid.

Adding and removing table columns

You can change the default set of columns displayed by the Network table. To show or hide a column, Right+click or Control+click (Mac only) in the table header and select or deselect column names from the list.

Changing resource row sizes

You can view the Network table with large resource rows (the default), or small resource rows. Click the blueUse small resource rows toggle button  at the bottom of the panel to view small rows. Click the same button (now gray ) to view large resource rows again. Large rows enable some columns to display two text fields: a primary field and a secondary field (Time and Latency, for instance). When viewing small rows only the primary field is displayed.

The network table with small resource rows and just the timeline column.

Waterfall view

The waterfall view in the network panel graphs the time it took to load each resource.From the start of the HTTP request to the receipt of the final byte of the response.

Each resource loading time is represented as a bar.This has color-coded information related to each resource.Each color specifies a different step needed to recieve the resource.The larger the bar grows represents more data being trasmitted for the request.

The network timeline for a simple web page.

Hovering your mouse over the bar itself will present the complete timing data.This is the same information that‘s presented in the Timing details tab for a given resource.

Network timing details revealed on hover.

The waterfall highlights DOMContentLoaded and load events display with blue and red vertical lines. When the engine has completed parsing of the main document the DOMContentLoaded event fires. Upon retrieving all the page‘s resources the load event will fire.

The event lines as displayed over the timeline.

You may enable in the network settings to view the timeline as color-coded by resource type.If you do the network timing information is still accessible through the tooltip.Waterfall bars are color-coded as follows:

  Documents
  Stylesheets
  Images
  Scripts
  XHR
  Fonts
  Other

Saving and copying network information

Right-clicking or Ctrl + Click (Mac only) within the Network table a context menu appears with several actions. Some of these actions apply to the resource row under the mouse click (like copying HTTP request headers), while others apply to the entire network recording (such as saving a Network recording as a HAR file).

The following menu actions apply to the selected resource:

  • Open Link in New Tab — Opens the resource in a new tab. You can also double-click the resource name in the Network table.
  • Copy Link Address — Copies the resource URL to the system clipboard.
  • Copy Request Headers — Copies the HTTP request headers to the system clipboard.
  • Copy Response Headers — Copies the HTTP response headers to the system clipboard.
  • Copy as cURL — Copies the network request as a cURL command string to the system clipboard. SeeCopying requests as cURL commands.
  • Replay XHR — If the associated request is an XMLHTTPRequest, re-sends the original XHR.

Copying requests as cURL commands

cURL is a command line tool for making HTTP transactions. The Network panel‘s Copy as cURL command recreates an HTTP request (including HTTP headers, SSL certificates, and query string parameters) and copies it as a cURL command string to the clipboard. You can then paste the string into a terminal window (on a system with cURL) to execute the same request.

Below is an example cURL command line string taken from a XHR request on the Google News home page.

curl ‘http://news.google.com/news/xhrd=us‘ -H ‘Accept-Encoding: gzip,deflate,:sdch‘ -H ‘Host: news.google.com‘ -H ‘Accept-Language: en-US,en;q=0.8‘ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1510.0 Safari/537.36‘ -H ‘Accept: */*‘ -H ‘Referer: http://news.google.com/nwshp?hl=en&tab=wn‘ -H ‘Cookie: NID=67=eruHSUtoIQA-HldQn7U7G5meGuvZOcY32ixQktdgU1qSz7StUDIjC_Knit2xEcWRa-e8CuvmADminmn6h2_IRpk9rWgWMdRj4np3-DM_ssgfeshItriiKsiEXJVfra4n; PREF=ID=a38f960566524d92:U=af866b8c07132db6:FF=0:TM=1369068317:LM=1369068321:S=vVkfXySFmOcAom1K‘ -H ‘Connection: keep-alive‘ --compressed

Saving network data

You can save the data from a network recording as a HAR (HTTP Archive) file, or copy the records as a HAR data structure to your clipboard. A HAR file contains a JSON data structure that describes the network "waterfall". Several third-party tools can reconstruct the network waterfall from the data in the HAR file.

To save a recording:

  1. Right+click or Control+click on the Network table.
  2. In the context menu that appears, choose one of the following actions:
    • Copy All as HAR — Copies the network recording to the system clipboard in the HAR format.
    • Save as HAR with Content — Saves all network data to a HAR file along with each page resource. Binary resources, including images, are encoded as Base64-encoded text.

For more information, Web Performance Power Tool: HTTP Archive (HAR).

Network resource details

When you click a resource name in the Network table a tabbed window appears that contains the following additional details:

HTTP headers

The Headers tab displays the resource‘s request URL, HTTP method, and response status code. Additionally, it lists the HTTP response and request headers and their values, and any query string parameters. You can view HTTP headers parsed and formatted, or in their source form by clicking the View parsed/View source toggle button, respectively, located next to each header‘s section. You can also view parameter values in their decoded or URL encoded forms by clicking the View decoded/View URL encoded toggle button next to each query string section.

You can also copy request and response headers to your clipboard.

Resource previews

The Preview tab displays a preview of the resource, when available. Previews are currently displayed for image and JSON resources, as shown below.

You can view the resource‘s unformatted response on the Responsetab.

HTTP response

The Response tab contains the resource‘s unformatted content. Below is a screenshot of a JSON data structure that was returned as the response for a request.

You can also view formatted previews of some resource types, including JSON data structures and images.

Cookies

The Cookies tab displays a table of all the cookies transmitted in theresource‘s HTTP request and response headers. You can also clear all cookies.

The Cookies table contain the following columns:

Name
The cookie‘s name.
Value
The value of the cookie.
Domain
The domain the cookie belongs to.
Path
The URL path the cookie came from.
Expires / Max-Age
The value of the cookie‘s expires or max-age properties.
Size
The size of the cookie in bytes.
HTTP
This indicates that the cookie should only be set by the browser in the HTTP request, and cannot be accessed with JavaScript.
Secure
The presence of this attribute indicates that the cookie should only be transmitted over a secure connection.

WebSocket frames

The Frames tab shows messages sent or received over a WebSocket connection. This tab is only visible when the selected resource initiated a WebSocket connection. The table contains the following columns:

Data
The message payload. If the message is plain text, it‘s displayed here. For binary opcodes, this field displays the opcode‘s name and code. The following opcodes are supported:

  • Continuation Frame
  • Binary Frame
  • Connection Close Frame
  • Ping Frame
  • Pong Frame
Length
The length of the message payload in bytes.
Time
The time stamp when the message was created.

Messages are color-coded according to their type. Outgoing text messages are color-coded light-green; incoming text messages are white:

WebSocket opcodes are light-yellow:

Errors are light-red.

Notes about current implementation:

  • To refresh the Frames table after new messages arrive, click the resource name on the left.
  • Only the last 100 WebSocket messages are preserved by the Frames table.

Resource network timing

The Timing tab graphs the time spent on the various network phases involved loading the resource. This is the same data displayed when you hover over a resource bar in the waterfall view.

Stalled/Blocking
Time the request spent waiting before it could be sent. This time is inclusive of any time spent in proxy negotiation. Additionally, this time will include when the browser is waiting for an already established connection to become available for re-use, obeying Chrome‘s maximum six TCP connection per origin rule.
Proxy Negotiation
Time spent negotiating with a proxy server connection.
DNS Lookup
Time spent performing the DNS lookup. Every new domain on a page requires a full roundtrip to do the DNS lookup.
Initial Connection / Connecting
Time it took to establish a connection, including TCP handshakes/retries and negotiating a SSL.
SSL
Time spent completing a SSL handshake.
Request Sent / Sending
Time spent issuing the network request. Typically a fraction of a millisecond.
Waiting (TTFB)
Time spent waiting for the initial response, also known as the Time To First Byte. This time captures the latency of a round trip to the server in addition to the time spent waiting for the server to deliver the response.
Content Download / Downloading
Time spent receiving the response data.

Additional resources

To learn more optimizing the network performance of your application, see the following resources:

【转载】https://developers.google.com/web/tools/profile-performance/network-performance/resource-loading

    https://developer.chrome.com/devtools/docs/network#resource-previews

时间: 2024-11-02 00:05:37

Google DevTools Explanation的相关文章

webapp网页调试工具Chrome Devtools

前言 css3说太多了,会显得文章显得千篇一律:介绍,介绍~demo,完结,然后就没有然后了.所以时不时插一篇扯蛋的玩意,起码还可以调节一下胃口,咸的辣的哪个喜欢就拿克(去). 之前想要测试手机demo的时候都要先把电脑屏幕拉窄,然后用自适应的办法来捣腾,但是我们都这样做其实并不是符合手机屏幕标准的.现在的智能手机都是以每英寸包含有多少像素点来衡量屏幕清晰度,而不是像PC端的屏幕清晰度都是以像素点来作为基准,因此假如老是按照拉窄屏幕来试图获取手机上显示效果显然不全对. 当然,作为一个非智能设备研

TensorFlow 初探

最近致力于深度学习,希望在移动领域能够找出更多的应用点.其中TensorFlow作为目前的一个热点值得我们重点关注. 机器学习 机器学习是人工智能的一个分支,也是用来实现人工只能的一种方法.简单来说,机器学习就是通过算法,使得机器能从大量历史数据中学习规律,从而对新的样本做智能识别或对未来做预测,与传统的使用特定指令集手写软件不同,我们使用大量数据和算法来"训练"机器,由此带来机器学习如何完成任务.从1980年代末期以来,机器学习的发展大致经历了两次浪潮:浅层学习(Shallow Le

Chrome 35个开发者工具的小技巧

来源:w3cplus - 南北(@ping4god) 网址:http://www.w3cplus.com/tools/dev-tips.html 谷歌浏览器如今是Web开发者们所使用的最流行的网页浏览器.伴随每六个星期一次的发布周期和不断扩大的强大的开发功能,Chrome变成了一个必须的工具.大多数可能熟悉关于chorme的许多特点,例如使用console和debugger在线编辑CSS.在这篇文章中,我们将分享一些很酷的技巧,让你能够更好的改进工作流程. 通过 console 面板修改页面元素

安装 Tensorflow

环境:Ubuntu 16.04  64bit 1.    安装Anaconda Anaconda 是 Python 的一个科学计算发行版,内置了数百个Python经常会使用的库,也包括了许多机器学习和数据挖掘依赖的库,包括 Scikit-learn.NumPy.SciPy 和 Pandas等,其中可能有一些还是 Tensorflow 的依赖库. Anaconda 提供了一个编译好的环境可以直接安装.同时 Anaconda 自动集成了最新版的MKL(Math Kernel Libaray)库,这是

使用webdriver出现的问题:[18796:1808:0730/131103.313:ERROR:install_util.cc(600)] Failed to read HKLM\SOFTWARE\Policies\Google\Chrome\MachineLevelUserCloudPolicyEnrollmentToken: 系统找不到指定的文件。 (0x2) DevTools lis

1.注册表导致 [5956:4996:0710/155156.898:ERROR:install_util.cc(589)] Unable to create registry key HKLM\SOFTWARE\Policies\Google\Chrome for reading result=2 找不到注册信息. 解决方法: 1)打开注册表编辑器 a) 快捷键win+R b) 输入:regedit c) 打开regedit.exe 2)找到并按顺序展开以下项目: -HKEY_LOCAL_MA

在浏览器上安装 Vue Devtools工具

Vue.js devtools是基于google chrome浏览器的一款调试vue.js应用的开发者浏览器扩展,可以在浏览器开发者工具下调试代码. 1)首先在github下载devtools源码,地址:https://github.com/vuejs/vue-devtools. 2)下载好后进入vue-devtools-master工程 执行cnpm install, 下载依赖,然后执行npm run build,编译源程序. 3)编译完成后,目录结构如下: 修改shells.chrome目录

How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7

How to install 64-bit Google Chrome 28+ on 64-bit RHEL/CentOS 6 or 7 The problem Google developers seem to think that Red Hat Enterprise Linux 6 - aka RHEL 6 - and its free equivalents (e.g. CentOS 6 and Scientific Linux 6) are no longer worth suppor

Google发布官方集成开发环境Android Studio 1.0

Google发布官方集成开发环境Android Studio 1.0    http://www.36kr.com/p/217653.html Android Studio系列教程一--下载与安装  http://stormzhang.com/devtools/2014/11/25/android-studio-tutorial1/ http://android-studio.org/

Teaching Your Computer To Play Super Mario Bros. – A Fork of the Google DeepMind Atari Machine Learning Project

Teaching Your Computer To Play Super Mario Bros. – A Fork of the Google DeepMind Atari Machine Learning Project Posted by ehrenbrav on August 25, 2016Leave a comment (14)Go to comments For those who want to get right to the good stuff, the installati