如何计算 Javascript 的带宽使用情况?
我想根据我在 Chrome 开发人员工具中看到的内容来计算某些 Javascript 代码将消耗多少带宽。
该脚本通过单行 Javascript 标签启动,引用外部 JS 文件。
在查看“启动器”和“大小”列时:
Initiator Size
-------------------------------------------
Default.aspx 4.39kb
Parser 10.54kb
该 Javascript 文件存在于我的服务器上,因此我想计算每个调用将从我的服务器连接(而不是 Default.aspx 所在的位置)消耗多少带宽。
所以我的服务器以 4.39kb 提供 .JS - 或者是请求的带宽消耗,而响应是 10.54kb?
解析器部分指的是什么?可以肯定地说,从我的服务器提供此请求 15.47kb 响应的总带宽使用量吗?
谢谢。
I want to calculate how much bandwidth a some Javascript code will consume, based on what I'm seeing in Chrome's developer tools.
The script is initiated through a one-liner Javascript tag, referencing the external JS file.
In the looking at the Initiator and Size Columns:
Initiator Size
-------------------------------------------
Default.aspx 4.39kb
Parser 10.54kb
That Javascript file exists on my server, so I want to calculate how much bandwidth each call will consume from my server connection (not where Default.aspx resides).
So my server serves up the .JS at 4.39kb - or is that the bandwidth consumption for the request, and the response is 10.54kb?
What does the parser portion refer to, and is it safe to say that the total bandwidth usage to serve up a response for this request 15.47kb from my server?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在发起者列中,第一行表示发起此请求的文件和行号。
第二行代表启动器的类型。
在您的情况下,此请求是由 HTML 解析器在解析 Default.aspx (我猜是您的主文档)时发起的。
从列标题中可以看到,在大小列中,第一行表示大小 - 表示传输大小,第二行表示内容大小 - 表示资源数据的实际大小。资源通常是压缩的,这可能是这种情况:
解压后响应大小为 4.39kb,脚本大小为 10.54kb。
没有关于请求大小的任何信息,但它通常非常小,除非您根据请求上传了一些数据。
请注意,在网络面板的底部有一行显示总请求数和总传输大小,这可能正是您所需要的。
In the initiator column first line represents file and line number where this request was initiated.
Second line represents the type of the initiator.
In your case this request was initiated by HTML parser while parsing Default.aspx (your main document I guess).
As you can see from column header, in the size column first line represents size - meaning transfer size, and the second line represents Content size - meaning actual size of the resource data. Resources are often served compressed and this is probably the case here:
response size was 4.39kb and script size was 10.54kb after decompression.
There is no any information about request size, but it is usually quite small unless you have uploaded some data by your request.
Please note that in the bottom of network panel there is a line showing total requests count and total transfer size which is probably what you need.
您读错了专栏。您看到的启动器的两个值与您看到的每个资源大小的两个值完全无关。
启动器的“Parser”值意味着解析器遇到
标记并加载它(或
标记,等等)。 “script”值意味着一段 JavaScript 要求加载资源(例如设置
的
src
或通过 AJAX)。“大小”列中的顶部值是 Chrome 所谓的“大小”,第二个(较小/灰色)值是“内容”。这些到底意味着什么,我正在努力弄清楚。
确实,总带宽使用量将是“大小”列中某些值的总和...但我不确定它是顶部值还是底部值。也与“始作俑者”完全无关。
You're reading the columns wrong. The two values for the initiator you're seeing are completely unrelated to the two values you're seeing for size for each resource.
The "Parser" value for the initiator means the parser came across a
<script>
tag and loaded it (or an<img>
tag, whatever). A "script" value means a piece of JavaScript demanded the loading of the resource (e.g. setting thesrc
of an<img/>
or via AJAX).The top value in the "Size" columns is what Chrome calls "Size" and the second (smaller/ gray) value is the "Content". Quite what these mean, I'm trying to work out.
It's true that the total bandwidth usage will be the sum of some values from the Size column... but I'm not sure whether it's the top or bottom value. It's also completely unrelated to the "Initiator".