工具来测量渲染时间 [英] Tool to measure Render time
问题描述
是否有一个工具那里来衡量一个页面上的元素(S)的实际渲染时间?我的意思不是资源的下载时间,但实际时间浏览了渲染的东西。我知道这一次会有所不同基于客户机上的因素,但仍是知道什么是渲染引擎需要一段时间来加载非常方便。我猜想这应该是一个有用的工具,因为Web应用程序正在成为pretty客户端重了。有什么想法?
Is there a tool out there to measure the actual Render time of an element(s) on a page? I don't mean download time of the resources, but the actual time the browser took to render something. I know that this time would vary based on factors on the client machine, but would still be very handy in knowing what the rendering engine takes a while to load. I would imagine this should be a useful utility since web apps are becoming pretty client heavy now. Any thoughts?
推荐答案
我一直在使用这个脚本来分析一些页面的渲染时间:
I've been using this script to analyze rendering time of some pages:
<script language="JavaScript">
<?
$output = str_replace('=', 'A', base64_encode(file_get_contents('data.txt')));
echo "\tCode = \"" . substr($output, 0, 512) . "\"";
$size = strlen($output);
for ($i = 512; $i < $size; $i += 512)
echo "\n\t + \"" . substr($output, $i, 512) . "\"";
echo ";\n";
?>
Data = "";
Dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
j = Code.length -3;
for (i = 0; i < j; i += 4) {
Data += String.fromCharCode(((Dict.indexOf(Code.charAt(i )) << 2) | (Dict.indexOf(Code.charAt(i + 1)) >> 4)) & 0xff);
Data += String.fromCharCode(((Dict.indexOf(Code.charAt(i + 1)) << 4) | (Dict.indexOf(Code.charAt(i + 2)) >> 2)) & 0xff);
Data += String.fromCharCode(((Dict.indexOf(Code.charAt(i + 2)) << 6) | (Dict.indexOf(Code.charAt(i + 3)) )) & 0xff);
}
time_start = (new Date).valueOf()/1000;
document.write(Data);
time_elapsed = (new Date).valueOf()/1000 - time_start;
alert(time_elapsed);
</script>
部分PHP,JavaScript的一部分。 的data.txt 是包含HTML来分析该文件。
测试在IE和FF。
Part PHP, part JavaScript. data.txt is the file containing the HTML to analyze. Tested on IE and FF.
这篇关于工具来测量渲染时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!