赞
踩
- 为什么要做前端监控
- 前端监控目标
- 前端监控流程
- 编写采集脚本
- 日志系统监控
- 错误监控
- 接口异常
- 白屏监控
- 加载时间
- 性能指标
- 卡顿
- pv
- 扩展问题
- 性能监控指标
- 前端怎么做性能监控
- 线上错误监控怎么做
- 导致内存泄漏的方法,怎么监控内存泄漏
- Node 怎么做性能监控
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GXA5Dhh3-1665996889919)(https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/bd91043540624db19d7bb390ee9752e4~tplv-k3u1fbpfcp-watermark.image?)]
{
"title": "前端监控系统", // 页面标题
"url": "http://localhost:8080/", // 页面URL
"timestamp": "1590815288710", // 访问时间戳
"userAgent": "Chrome", // 用户浏览器类型
"kind": "stability", // 大类
"type": "error", // 小类
"errorType": "jsError", // 错误类型
"message": "Uncaught TypeError: Cannot set property 'error' of undefined", // 类型详情
"filename": "http://localhost:8080/", // 访问的文件名
"position": "0:0", // 行列信息
"stack": "btnClick (http://localhost:8080/:20:39)^HTMLInputElement.onclick (http://localhost:8080/:14:72)", // 堆栈信息
"selector": "HTML BODY #container .content INPUT" // 选择器
}
{
...
"errorType": "promiseError",//错误类型
"message": "someVar is not defined",//类型详情
"stack": "http://localhost:8080/:24:29^new Promise (<anonymous>)^btnPromiseClick (http://localhost:8080/:23:13)^HTMLInputElement.onclick (http://localhost:8080/:15:86)",//堆栈信息
"selector": "HTML BODY #container .content INPUT"//选择器
}
...
"errorType": "resourceError",//错误类型
"filename": "http://localhost:8080/error.js",//访问的文件名
"tagName": "SCRIPT",//标签名
"timeStamp": "76",//时间
//一般JS运行时错误使用window.onerror捕获处理 window.addEventListener( "error", function (event) { let lastEvent = getLastEvent(); // 有 e.target.src(href) 的认定为资源加载错误 if (event.target && (event.target.src || event.target.href)) { tracker.send({ //资源加载错误 kind: "stability", //稳定性指标 type: "error", //resource errorType: "resourceError", filename: event.target.src || event.target.href, //加载失败的资源 tagName: event.target.tagName, //标签名 timeStamp: formatTime(event.timeStamp), //时间 selector: getSelector(event.path || event.target), //选择器 }); } else { tracker.send({ kind: "stability", //稳定性指标 type: "error", //error errorType: "jsError", //jsError message: event.message, //报错信息 filename: event.filename, //报错链接 position: (event.lineNo || 0) + ":" + (event.columnNo || 0), //行列号 stack: getLines(event.error.stack), //错误堆栈 selector: lastEvent ? getSelector(lastEvent.path || lastEvent.target) : "", //CSS选择器 }); } }, true ); // true代表在捕获阶段调用,false代表在冒泡阶段捕获,使用true或false都可以
//当Promise 被 reject 且没有 reject 处理器的时候,会触发 unhandledrejection 事件 window.addEventListener( "unhandledrejection", function (event) { let lastEvent = getLastEvent(); let message = ""; let line = 0; let column = 0; let file = ""; let stack = ""; if (typeof event.reason === "string") { message = event.reason; } else if (typeof event.reason === "object") { message = event.reason.message; } let reason = event.reason; if (typeof reason === "object") { if (reason.stack) { var matchResult = reason.stack.match(/at\s+(.+):(\d+):(\d+)/); if (matchResult) { file = matchResult[1]; line = matchResult[2]; column = matchResult[3]; } stack = getLines(reason.stack); } } tracker.send({ //未捕获的promise错误 kind: "stability", //稳定性指标 type: "error", //jsError errorType: "promiseError", //unhandledrejection message: message, //标签名 filename: file, position: line + ":" + column, //行列 stack, selector: lastEvent ? getSelector(lastEvent.path || lastEvent.target) : "", }); }, true ); // true代表在捕获阶段调用,false代表在冒泡阶段捕获,使用true或false都可以
{
"title": "前端监控系统", //标题
"url": "http://localhost:8080/", //url
"timestamp": "1590817024490", //timestamp
"userAgent": "Chrome", //浏览器版本
"kind": "stability", //大类
"type": "xhr", //小类
"eventType": "load", //事件类型
"pathname": "/success", //路径
"status": "200-OK", //状态码
"duration": "7", //持续时间
"response": "{\"id\":1}", //响应内容
"params": "" //参数
}
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590817025617",
"userAgent": "Chrome",
"kind": "stability",
"type": "xhr",
"eventType": "load",
"pathname": "/error",
"status": "500-Internal Server Error",
"duration": "7",
"response": "",
"params": "name=zhufeng"
}
使用webpack devServer模拟请求
import tracker from "../util/tracker"; export function injectXHR() { let XMLHttpRequest = window.XMLHttpRequest; let oldOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function ( method, url, async, username, password ) { // 上报的接口不用处理 if (!url.match(/logstores/) && !url.match(/sockjs/)) { this.logData = { method, url, async, username, password, }; } return oldOpen.apply(this, arguments); }; let oldSend = XMLHttpRequest.prototype.send; let start; XMLHttpRequest.prototype.send = function (body) { if (this.logData) { start = Date.now(); let handler = (type) => (event) => { let duration = Date.now() - start; let status = this.status; let statusText = this.statusText; tracker.send({ //未捕获的promise错误 kind: "stability", //稳定性指标 type: "xhr", //xhr eventType: type, //load error abort pathname: this.logData.url, //接口的url地址 status: status + "-" + statusText, duration: "" + duration, //接口耗时 response: this.response ? JSON.stringify(this.response) : "", params: body || "", }); }; this.addEventListener("load", handler("load"), false); this.addEventListener("error", handler("error"), false); this.addEventListener("abort", handler("abort"), false); } oldSend.apply(this, arguments); }; }
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590822618759",
"userAgent": "chrome",
"kind": "stability", //大类
"type": "blank", //小类
"emptyPoints": "0", //空白点
"screen": "2049x1152", //分辨率
"viewPoint": "2048x994", //视口
"selector": "HTML BODY #container" //选择器
}
import tracker from "../util/tracker"; import onload from "../util/onload"; function getSelector(element) { var selector; if (element.id) { selector = `#${element.id}`; } else if (element.className && typeof element.className === "string") { selector = "." + element.className .split(" ") .filter(function (item) { return !!item; }) .join("."); } else { selector = element.nodeName.toLowerCase(); } return selector; } export function blankScreen() { const wrapperSelectors = ["body", "html", "#container", ".content"]; let emptyPoints = 0; function isWrapper(element) { let selector = getSelector(element); if (wrapperSelectors.indexOf(selector) >= 0) { emptyPoints++; } } onload(function () { let xElements, yElements; debugger; for (let i = 1; i <= 9; i++) { xElements = document.elementsFromPoint( (window.innerWidth * i) / 10, window.innerHeight / 2 ); yElements = document.elementsFromPoint( window.innerWidth / 2, (window.innerHeight * i) / 10 ); isWrapper(xElements[0]); isWrapper(yElements[0]); } if (emptyPoints >= 0) { let centerElements = document.elementsFromPoint( window.innerWidth / 2, window.innerHeight / 2 ); tracker.send({ kind: "stability", type: "blank", emptyPoints: "" + emptyPoints, screen: window.screen.width + "x" + window.screen.height, viewPoint: window.innerWidth + "x" + window.innerHeight, selector: getSelector(centerElements[0]), }); } }); } //screen.width 屏幕的宽度 screen.height 屏幕的高度 //window.innerWidth 去除工具条与滚动条的窗口宽度 window.innerHeight 去除工具条与滚动条的窗口高度
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5HB2c44P-1665996889921)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7d30801313694b8bbf1e8977b8d8bd45~tplv-k3u1fbpfcp-watermark.image?)]
字段 | 含义 |
---|---|
navigationStart | 初始化页面,在同一个浏览器上下文中前一个页面unload的时间戳,如果没有前一个页面的unload,则与fetchStart值相等 |
redirectStart | 第一个HTTP重定向发生的时间,有跳转且是同域的重定向,否则为0 |
redirectEnd | 最后一个重定向完成时的时间,否则为0 |
fetchStart | 浏览器准备好使用http请求获取文档的时间,这发生在检查缓存之前 |
domainLookupStart | DNS域名开始查询的时间,如果有本地的缓存或keep-alive则时间为0 |
domainLookupEnd | DNS域名结束查询的时间 |
connectStart | TCP开始建立连接的时间,如果是持久连接,则与fetchStart 值相等 |
secureConnectionStart | https 连接开始的时间,如果不是安全连接则为0 |
connectEnd | TCP完成握手的时间,如果是持久连接则与fetchStart 值相等 |
requestStart | HTTP请求读取真实文档开始的时间,包括从本地缓存读取 |
requestEnd | HTTP请求读取真实文档结束的时间,包括从本地缓存读取 |
responseStart | 返回浏览器从服务器收到(或从本地缓存读取)第一个字节时的Unix毫秒时间戳 |
responseEnd | 返回浏览器从服务器收到(或从本地缓存读取,或从本地资源读取)最后一个字节时的Unix毫秒时间戳 |
unloadEventStart | 前一个页面的unload的时间戳 如果没有则为0 |
unloadEventEnd | 与unloadEventStart 相对应,返回的是unload 函数执行完成的时间戳 |
domLoading | 返回当前网页DOM结构开始解析时的时间戳,此时document.readyState 变成loading,并将抛出readyStateChange 事件 |
domInteractive | 返回当前网页DOM结构结束解析、开始加载内嵌资源时时间戳,document.readyState 变成interactive ,并将抛出readyStateChange 事件(注意只是DOM树解析完成,这时候并没有开始加载网页内的资源) |
domContentLoadedEventStart | 网页domContentLoaded事件发生的时间 |
domContentLoadedEventEnd | 网页domContentLoaded事件脚本执行完毕的时间,domReady的时间 |
domComplete | DOM树解析完成,且资源也准备就绪的时间,document.readyState 变成complete .并将抛出readystatechange 事件 |
loadEventStart | load 事件发送给文档,也即load回调函数开始执行的时间 |
loadEventEnd | load回调函数执行完成的时间 |
字段 | 描述 | 计算方式 | 意义 |
---|---|---|---|
unload | 前一个页面卸载耗时 | unloadEventEnd – unloadEventStart | - |
redirect | 重定向耗时 | redirectEnd – redirectStart | 重定向的时间 |
appCache | 缓存耗时 | domainLookupStart – fetchStart | 读取缓存的时间 |
dns | DNS 解析耗时 | domainLookupEnd – domainLookupStart | 可观察域名解析服务是否正常 |
tcp | TCP 连接耗时 | connectEnd – connectStart | 建立连接的耗时 |
ssl | SSL 安全连接耗时 | connectEnd – secureConnectionStart | 反映数据安全连接建立耗时 |
ttfb | Time to First Byte(TTFB)网络请求耗时 | responseStart – requestStart | TTFB是发出页面请求到接收到应答数据第一个字节所花费的毫秒数 |
response | 响应数据传输耗时 | responseEnd – responseStart | 观察网络是否正常 |
dom | DOM解析耗时 | domInteractive – responseEnd | 观察DOM结构是否合理,是否有JS阻塞页面解析 |
dcl | DOMContentLoaded 事件耗时 | domContentLoadedEventEnd – domContentLoadedEventStart | 当 HTML 文档被完全加载和解析完成之后,DOMContentLoaded 事件被触发,无需等待样式表、图像和子框架的完成加载 |
resources | 资源加载耗时 | domComplete – domContentLoadedEventEnd | 可观察文档流是否过大 |
domReady | DOM阶段渲染耗时 | domContentLoadedEventEnd – fetchStart | DOM树和页面资源加载完成时间,会触发domContentLoaded 事件 |
首次渲染耗时 | 首次渲染耗时 | responseEnd-fetchStart | 加载文档到看到第一帧非空图像的时间,也叫白屏时间 |
首次可交互时间 | 首次可交互时间 | domInteractive-fetchStart | DOM树解析完成时间,此时document.readyState为interactive |
首包时间耗时 | 首包时间 | responseStart-domainLookupStart | DNS解析到响应返回给浏览器第一个字节的时间 |
页面完全加载时间 | 页面完全加载时间 | loadEventStart - fetchStart | - |
onLoad | onLoad事件耗时 | loadEventEnd – loadEventStart |
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3Spbnyec-1665996889921)(https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/19ac271140f74522b13dabe05cb4a0c8~tplv-k3u1fbpfcp-watermark.image?)]
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590828364183",
"userAgent": "chrome",
"kind": "experience",
"type": "timing",
"connectTime": "0",
"ttfbTime": "1",
"responseTime": "1",
"parseDOMTime": "80",
"domContentLoadedTime": "0",
"timeToInteractive": "88",
"loadTime": "89"
}
import onload from "../util/onload"; import tracker from "../util/tracker"; import formatTime from "../util/formatTime"; import getLastEvent from "../util/getLastEvent"; import getSelector from "../util/getSelector"; export function timing() { onload(function () { setTimeout(() => { const { fetchStart, connectStart, connectEnd, requestStart, responseStart, responseEnd, domLoading, domInteractive, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, } = performance.timing; tracker.send({ kind: "experience", type: "timing", connectTime: connectEnd - connectStart, //TCP连接耗时 ttfbTime: responseStart - requestStart, //ttfb responseTime: responseEnd - responseStart, //Response响应耗时 parseDOMTime: loadEventStart - domLoading, //DOM解析渲染耗时 domContentLoadedTime: domContentLoadedEventEnd - domContentLoadedEventStart, //DOMContentLoaded事件回调耗时 timeToInteractive: domInteractive - fetchStart, //首次可交互时间 loadTime: loadEventStart - fetchStart, //完整的加载时间 }); }, 3000); }); }
字段 | 描述 | 备注 | 计算方式 |
---|---|---|---|
FP | First Paint(首次绘制) | 包括了任何用户自定义的背景绘制,它是首先将像素绘制到屏幕的时刻 | |
FCP | First Content Paint(首次内容绘制) | 是浏览器将第一个 DOM 渲染到屏幕的时间,可能是文本、图像、SVG等,这其实就是白屏时间 | |
FMP | First Meaningful Paint(首次有意义绘制) | 页面有意义的内容渲染的时间 | |
LCP | (Largest Contentful Paint)(最大内容渲染) | 代表在viewport中最大的页面元素加载的时间 | |
DCL | (DomContentLoaded)(DOM加载完成) | 当 HTML 文档被完全加载和解析完成之后, DOMContentLoaded 事件被触发,无需等待样式表、图像和子框架的完成加载 | |
L | (onLoad) | 当依赖的资源全部加载完毕之后才会触发 | |
TTI | (Time to Interactive) 可交互时间 | 用于标记应用已进行视觉渲染并能可靠响应用户输入的时间点 | |
FID | First Input Delay(首次输入延迟) | 用户首次和页面交互(单击链接,点击按钮等)到页面响应交互的时间 |
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-frx6x0Sw-1665996889922)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/3421a08b415145a08d438dc457b57860~tplv-k3u1fbpfcp-watermark.image?)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-o8Xxqvuv-1665996889922)(https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/b9a4cc37d8eb44be883fc40f2d0093e1~tplv-k3u1fbpfcp-watermark.image?)]
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590828364186",
"userAgent": "chrome",
"kind": "experience",
"type": "paint",
"firstPaint": "102",
"firstContentPaint": "2130",
"firstMeaningfulPaint": "2130",
"largestContentfulPaint": "2130"
}
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590828477284",
"userAgent": "chrome",
"kind": "experience",
"type": "firstInputDelay",
"inputDelay": "3",
"duration": "8",
"startTime": "4812.344999983907",
"selector": "HTML BODY #container .content H1"
}
关键时间节点通过window.performance.timing获取
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sdVpxVqP-1665996889922)(https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9369074ff2554710abad169c8ba772ba~tplv-k3u1fbpfcp-watermark.image?)]
import tracker from "../utils/tracker"; import onload from "../utils/onload"; import getLastEvent from "../utils/getLastEvent"; import getSelector from "../utils/getSelector"; export function timing() { let FMP, LCP; // 增加一个性能条目的观察者 new PerformanceObserver((entryList, observer) => { const perfEntries = entryList.getEntries(); FMP = perfEntries[0]; observer.disconnect(); // 不再观察了 }).observe({ entryTypes: ["element"] }); // 观察页面中有意义的元素 // 增加一个性能条目的观察者 new PerformanceObserver((entryList, observer) => { const perfEntries = entryList.getEntries(); const lastEntry = perfEntries[perfEntries.length - 1]; LCP = lastEntry; observer.disconnect(); // 不再观察了 }).observe({ entryTypes: ["largest-contentful-paint"] }); // 观察页面中最大的元素 // 增加一个性能条目的观察者 new PerformanceObserver((entryList, observer) => { const lastEvent = getLastEvent(); const firstInput = entryList.getEntries()[0]; if (firstInput) { // 开始处理的时间 - 开始点击的时间,差值就是处理的延迟 let inputDelay = firstInput.processingStart - firstInput.startTime; let duration = firstInput.duration; // 处理的耗时 if (inputDelay > 0 || duration > 0) { tracker.send({ kind: "experience", // 用户体验指标 type: "firstInputDelay", // 首次输入延迟 inputDelay: inputDelay ? formatTime(inputDelay) : 0, // 延迟的时间 duration: duration ? formatTime(duration) : 0, startTime: firstInput.startTime, // 开始处理的时间 selector: lastEvent ? getSelector(lastEvent.path || lastEvent.target) : "", }); } } observer.disconnect(); // 不再观察了 }).observe({ type: "first-input", buffered: true }); // 第一次交互 // 刚开始页面内容为空,等页面渲染完成,再去做判断 onload(function () { setTimeout(() => { const { fetchStart, connectStart, connectEnd, requestStart, responseStart, responseEnd, domLoading, domInteractive, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, } = window.performance.timing; // 发送时间指标 tracker.send({ kind: "experience", // 用户体验指标 type: "timing", // 统计每个阶段的时间 connectTime: connectEnd - connectStart, // TCP连接耗时 ttfbTime: responseStart - requestStart, // 首字节到达时间 responseTime: responseEnd - responseStart, // response响应耗时 parseDOMTime: loadEventStart - domLoading, // DOM解析渲染的时间 domContentLoadedTime: domContentLoadedEventEnd - domContentLoadedEventStart, // DOMContentLoaded事件回调耗时 timeToInteractive: domInteractive - fetchStart, // 首次可交互时间 loadTime: loadEventStart - fetchStart, // 完整的加载时间 }); // 发送性能指标 let FP = performance.getEntriesByName("first-paint")[0]; let FCP = performance.getEntriesByName("first-contentful-paint")[0]; console.log("FP", FP); console.log("FCP", FCP); console.log("FMP", FMP); console.log("LCP", LCP); tracker.send({ kind: "experience", type: "paint", firstPaint: FP ? formatTime(FP.startTime) : 0, firstContentPaint: FCP ? formatTime(FCP.startTime) : 0, firstMeaningfulPaint: FMP ? formatTime(FMP.startTime) : 0, largestContentfulPaint: LCP ? formatTime(LCP.renderTime || LCP.loadTime) : 0, }); }, 3000); }); }
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590828656781",
"userAgent": "chrome",
"kind": "experience",
"type": "longTask",
"eventType": "mouseover",
"startTime": "9331",
"duration": "200",
"selector": "HTML BODY #container .content"
}
import tracker from "../util/tracker"; import formatTime from "../util/formatTime"; import getLastEvent from "../util/getLastEvent"; import getSelector from "../util/getSelector"; export function longTask() { new PerformanceObserver((list) => { list.getEntries().forEach((entry) => { if (entry.duration > 100) { let lastEvent = getLastEvent(); requestIdleCallback(() => { tracker.send({ kind: "experience", type: "longTask", eventType: lastEvent.type, startTime: formatTime(entry.startTime), // 开始时间 duration: formatTime(entry.duration), // 持续时间 selector: lastEvent ? getSelector(lastEvent.path || lastEvent.target) : "", }); }); } }); }).observe({ entryTypes: ["longtask"] }); }
{
"title": "前端监控系统",
"url": "http://localhost:8080/",
"timestamp": "1590829304423",
"userAgent": "chrome",
"kind": "business",
"type": "pv",
"effectiveType": "4g",
"rtt": "50",
"screen": "2049x1152"
}
PV(page view) 是页面浏览量,UV(Unique visitor)用户访问量。PV 只要访问一次页面就算一次,UV 同一天内多次访问只算一次。
对于前端来说,只要每次进入页面上报一次 PV 就行,UV 的统计放在服务端来做,主要是分析上报的数据来统计得出 UV。
import tracker from "../util/tracker"; export function pv() { tracker.send({ kind: "business", type: "pv", startTime: performance.now(), pageURL: getPageURL(), referrer: document.referrer, uuid: getUUID(), }); let startTime = Date.now(); window.addEventListener( "beforeunload", () => { let stayTime = Date.now() - startTime; tracker.send({ kind: "business", type: "stayTime", stayTime, pageURL: getPageURL(), uuid: getUUID(), }); }, false ); }
指标 | 名称 | 解释 |
---|---|---|
FP | First-Paint 首次渲染 | 表示浏览器从开始请求网站到屏幕渲染第一个像素点的时间 |
FCP | First-Contentful-Paint 首次内容渲染 | 表示浏览器渲染出第一个内容的时间,这个内容可以是文本、图片或SVG元素等等,不包括iframe和白色背景的canvas元素 |
SI | Speed Index 速度指数 | 表明了网页内容的可见填充速度 |
LCP | Largest Contentful Paint 最大内容绘制 | 标记了渲染出最大文本或图片的时间 |
TTI | Time to Interactive 可交互时间 | 页面从开始加载到主要子资源完成渲染,并能够快速、可靠的响应用户输入所需的时间 |
TBT | Total Blocking Time 总阻塞时间 | 测量 FCP 与 TTI 之间的总时间,这期间,主线程被阻塞的时间过长,无法作出输入响应 |
FID | First Input Delay 首次输入延迟 | 测量加载响应度的一个以用户为中心的重要指标 |
CLS | Cumulative Layout Shift 累积布局偏移 | 测量的是整个页面生命周期内发生的所有意外布局偏移中最大一连串的布局偏移分数 |
DCL | DOMContentLoaded | 当初始的 HTML 文档被完全加载和解析完成之后,DOMContentLoaded 事件被触发,而无需等待样式表、图像和子框架的完成加载 |
L | Load | 检测一个完全加载的页面,页面的html、css、js、图片等资源都已经加载完之后才会触发 load 事件 |
const { fetchStart, connectStart, connectEnd, requestStart, responseStart, responseEnd, domLoading, domInteractive, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, } = window.performance.timing; const obj = { kind: "experience", // 用户体验指标 type: "timing", // 统计每个阶段的时间 dnsTime: domainLookupEnd - domainLookupStart, // DNS查询时间 connectTime: connectEnd - connectStart, // TCP连接耗时 ttfbTime: responseStart - requestStart, // 首字节到达时间 responseTime: responseEnd - responseStart, // response响应耗时 parseDOMTime: loadEventStart - domLoading, // DOM解析渲染的时间 domContentLoadedTime: domContentLoadedEventEnd - domContentLoadedEventStart, // DOMContentLoaded事件回调耗时 timeToInteractive: domInteractive - fetchStart, // 首次可交互时间 loadTime: loadEventStart - fetchStart, // 完整的加载时间 }
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wXdOHfqs-1665996889923)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/b004ba190b0c49a99959539bc7e79a8c~tplv-k3u1fbpfcp-watermark.image?)]
监控内存泄漏
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zRsOyVWG-1665996889923)(https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/090ce23e973e4a29820d2f1027736dc9~tplv-k3u1fbpfcp-watermark.image?)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。