Closed Liu6625 closed 1 year ago
Hi @Liu6625 can you give me an concrete example, I don't fully get it?
For example, the json data generated by terminal npx browsertime https://www.sitespeed.io/ is inconsistent with the result returned by codeconst browser = await new BrowsertimeEngine({browser: 'chrome'}) await browser.start(); let result = await browser.run('https://www.sitespeed.io/', {});
你好@Liu6625你能给我一个具体的例子吗,我不太明白?
I want to get the results directly in the form of code instead of reading the generated json data, such as the following
Can you explain what you mean by inconsistent, I don't fully get what you mean. Thanks!
可以解释一下你所说的不一致是什么意思,我不完全明白你的意思。谢谢!
The data in browsertime.json generated by npx browsertime is more detailed than the data returned by BrowsertimeEngine operation. For example, there are indicators such as googleWebVitals, TTFB, firstPaint, FCP, LCP, TBT, etc. in browsertime.json, and the results returned by the latter are only simple indicators of mainDocumentTimings
Can you explain what you mean by inconsistent, I don't fully get what you mean. Thanks!
I want to run the returned execution results through the BrowsertimeEngine instance also have those performance indicators in the json file generated by npx Browsertime
. Thanks!
Ok, I think I understand what you mean. The reason from the beginning is that when you run Browsertime directly from Node, it's completely blank, so you need to add the JavaScript collectors yourself. In sitespeed.io that is done in https://github.com/sitespeedio/sitespeed.io/blob/main/lib/plugins/browsertime/analyzer.js that you can use as example code. It's not super clean but at least its code that work.
好吧,我想我明白你的意思了。从一开始的原因是,当您直接从 Node 运行 Browsertime 时,它是完全空白的,因此您需要自己添加 JavaScript 收集器。在 sitespeed.io 中,这是在https://github.com/sitespeedio/sitespeed.io/blob/main/lib/plugins/browsertime/analyzer.js中完成的,您可以将其用作示例代码。它不是超级干净,但至少它的代码可以工作。
Thank you very much, this is a very effective method. I didn’t know the use of other default export methods in the browsertime library before. It turned out to be used in this way. Thanks again
Your question
Why are the results obtained by using browsertime with node inconsistent with the results returned by browsertimeEngine.run? If browsertimeEngine.run is used to return the results of browsertime