网站性能测试:如何最好地估算计算机性能? [英] Website Performance Testing: How best to approximate computer performance?

查看:157
本文介绍了网站性能测试:如何最好地估算计算机性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页上有一些浏览器密集型的CSS和动画,我想确定用户是否有快速PC,因此我可以相应地扩展内容以提供最佳体验。

I have some browser-intensive CSS and animation in my webpage and I'd like to determine if the user has a fast PC or not so i can scale things accordingly to provide the best experience.

我正在使用 http://detectmobilebrowser.com 用于检测所有移动设备的脚本,我将包含 /android|ipad|ipod|playbook | silk / i.test(a)条款以包含所有平板电脑设备同样。

I am using http://detectmobilebrowser.com's script to detect all mobile devices, and I am going to include the clause /android|ipad|ipod|playbook|silk/i.test(a) to include all tablet devices as well.

然而,这不能也无法真正解决实际的硬件问题。绘制一张我正在寻找的图片并不是很遥远。

However this doesn't and cannot really address the actual hardware. It doesn't go very far at all to paint a picture of what I'm looking for.

例如,iPhone 4S的功能将远远超过移动用户代理检测器匹配的许多设备,而这对于它无法实现把自己分开了。
有人可能会在奔腾II机器上运行谷歌浏览器(不知何故)并希望查看我的页面。 (这个人可能没有iPhone 4S)

An iPhone 4S, for example, will be quite a lot more capable than many of the devices matched by the mobile user agent detector, and this provides no way for it to set itself apart. Somebody might run Google Chrome on a Pentium II machine (somehow) and want to view my page. (This person probably does not have an iPhone 4S)

显然要真正了解这一点我必须做一些实际的性能测试,并且与性能测试一样对于任何类型的应用程序,仅测试应用程序实际执行的任务类型的性能是有意义的。

Obviously to actually get an idea for this I'll have to do some actual performance testing, and as with performance testing with any kind of application, it makes sense to only test the performance of the type of tasks that the application actually performs.

即使考虑到这一点,我觉得在性能测试程序花费太长时间并且用户变得不耐烦之前,很难获得任何合理准确的数字。所以这可能意味着继续它,除非我希望第一次初步印象是完美的。嗯,事实恰恰是这种情况。因此,我无法在第一次运行后测量性能并稍后调整参数。

Even with this in mind I feel like it would be difficult to obtain any reasonably accurate numbers before the performance testing routine will have taken too long and the user will have became impatient. So this probably means go ahead with it unless I want the first initial impression to be perfect. Well, this actually happens to be the case. So I can't get away with measuring performance "after the first run" and adjusting the parameters later.

所以我剩下的就是基本上尝试在初始页面加载时执行类似的任务,其方式取决于浏览器渲染和处理速度,而不向用户呈现任何内容(以便他们仍然认为页面正在加载),然后最好在一两秒钟内获得足够准确的数字,以便为实际页面设置参数,使其生动并以令人愉悦的方式呈现像幻灯片一样。

So what I've got left is to basically try to perform a similar task on initial page load, in a way that is dependent on browser rendering and processing speed, while not presenting anything to the user (so that to the user they still think the page is loading), and then preferably within a second or two obtain accurate enough numbers to set parameters for the actual page to animate and present in a pleasing manner that doesn't resemble a slideshow.

也许我可以在我的测试用例中放置一个整页白色< div> ,这样我就可以防止用户不会看到正在发生的事情,并希望通过避免完成所有工作来使浏览器不智能。

Maybe I could place a full-page white <div> over my test case so that I can prevent the user from seeing what's going on and hope that the browser will not be smart by avoiding doing all the work.

有没有人这样做过?

我知道人们会说,你可能不需要这样做,或必须有更好的方式或减少数量效果。

I know people are going to say, "you probably don't need to do this", or "there's gotta be a better way" or "reduce the amount of effects".

我在页面上做的任何事情的原因是看起来不错。这就是它的全部观点。如果我不关心这个问题就不会存在。目标是让javascript能够确定足够的参数,以便在功能强大的计算机上提供令人敬畏的体验,并在功能较弱的计算机上提供可通过的体验。当有更多电力时,应该利用它。所以希望这可以解释为什么这些建议不是问题的有效答案。

The reason for doing any of the things I'm doing on the page are so that it looks good. That's the entire point of it. If I didn't care about that as much this question wouldn't exist. The goal is to give the javascript the ability to determine enough parameters to provide an awesome experience on a powerful computer, and also a passable experience on a less capable computer. When more power is available, it should be harnessed. So hopefully that can explain why such suggestions are not valid answers to the question.

推荐答案

我不是一次测量用户的CPU性能,而是确定要使用多少花哨的视觉效果,我会测量金额每次执行时使用CPU密集位所花费的时间(使用 new Date()),将其与预期的最小值和最大值进行比较(您必须确定),并根据需要动态调整效果级别。

Rather than measuring the user's CPU performance once and determining how many fancy visual effects to use from that, I would measure the amount of time taken by the CPU-intensive bits every time they execute (using new Date()), compare that to expected minimum and maximum values (which you will have to determine), and dynamically adjust the "effect level" up and down as appropriate.

说用户是否在后台启动了一个程序很多CPU时间。如果你使用这个想法,你的页面将自动降低视觉效果,以节省CPU周期。当后台程序结束时,花哨的效果将会回来。我不知道你的用户是否会喜欢这种效果(但我确信他们会喜欢他们的浏览器在CPU过载时保持响应的事实)。

Say if the user starts up a program in the background which eats a lot of CPU time. If you use this idea, your page will automatically tone down the visual effects to save CPU cycles. When the background program finishes, the fancy effects will come back. I don't know if your users will like this effect (but I am sure they will like the fact that their browser stays responsive when the CPU is overloaded).

这篇关于网站性能测试:如何最好地估算计算机性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆