简体   繁体   English

Javascript大小和下载速度

[英]Javascript size and download speed

I have a bunch of javascript/css/img sources. 我有一堆javascript / css / img来源。 I want to calculate their size and how long it takes for me to download them. 我想计算它们的大小以及我下载它们需要多长时间。 Is that possible using cURL? 使用cURL可以吗? Would like to see a suggestion on what cURL function should i use for this. 希望看到关于我应该使用哪种cURL函数的建议。 Or shoud i use something else for this? 还是应该为此使用其他东西?

I don't really know about curl in this context, but a useful tool for that is the "Why Slow" or YSlow extension for Firefox : 在这种情况下,我并不是很了解curl,但是对此有用的工具是Firefox的“为什么慢”或YSlow扩展名:

https://addons.mozilla.org/en-US/firefox/addon/yslow/ https://addons.mozilla.org/zh-CN/firefox/addon/yslow/

It analyses every resource donwloaded by your page, a dpresents it in a very useful manner, with the milliseconds used by each resource etc. It also gives hints how you can improve the results. 它分析了您的页面下载的每个资源,并以一种非常有用的方式表示了该资源,以及每个资源使用的毫秒数等。它还提示了如何改善结果。

YSlow can also be integrated in Firebug. YSlow也可以集成在Firebug中。

Of course, what it gives you depends strongly on the connection you use, and the result will differ depending on each connection used by each client. 当然,它为您提供的功能在很大程度上取决于您使用的连接,并且结果将取决于每个客户端使用的每个连接而有所不同。 However it gives you a good general idea of which resources are using up brandwith, where bottlenecks are etc. 但是,它可以使您大致了解哪些资源正在耗尽brandwith,瓶颈在哪里等。

You can not do a precalculation with curl. 您无法使用curl进行预先计算。

But you can post-calculate using curl_getinfo after you do the request. 但是,您可以执行请求使用curl_getinfo进行 计算

It will return an array of information about the request. 它将返回有关请求的信息数组。

The keys of this array you will need are: 您将需要的该数组的键为:

CURLINFO_TOTAL_TIME - Total transaction time in seconds for last transfer CURLINFO_NAMELOOKUP_TIME - Time in seconds until name resolving was complete CURLINFO_CONNECT_TIME - Time in seconds it took to establish the connection CURLINFO_PRETRANSFER_TIME - Time in seconds from start until just before file transfer begins CURLINFO_STARTTRANSFER_TIME - Time in seconds until the first byte is about to be transferred CURLINFO_TOTAL_TIME-上次传输的总交易时间(以秒为单位)CURLINFO_NAMELOOKUP_TIME-直到名称解析完成的时间(以秒为单位)CURLINFO_CONNECT_TIME-建立连接所花费的时间(单位为秒)CURLINFO_PRETRANSFER_TIME-从开始到文件传输开始之前的时间(以秒为单位)CURLINFO_STARTTRANSFER_TIME(秒)第一个字节即将被传输

And for the size: 对于大小:

CURLINFO_SIZE_UPLOAD - Total number of bytes uploaded CURLINFO_SIZE_UPLOAD-上传的字节总数
CURLINFO_SIZE_DOWNLOAD - Total number of bytes downloaded CURLINFO_SIZE_DOWNLOAD-下载的字节总数

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM