简体   繁体   English

是否可以在浏览器中使用javascript对用户的系统进行基准测试

[英]Is it possible to benchmark a user's system with javascript in the browser

As Html5 starts gaining ground, we are seeing more experiments with things like the video or canvas element. 随着Html5的开始,我们看到了更多关于视频或画布元素的实验。

When making an experiment with the canvas for example making a firework with particles, 1000 particles may work well on a modern machine but may go very slowly on a 3yr machine. 当用帆布进行实验时,例如制作带有颗粒的烟花,1000颗粒可以在现代机器上很好地工作,但在3年的机器上可能会非常慢。

Is there anyway to benchmark a users system to dynamically change a canvas experiment (or anything) so as to optimise it to said specific user. 无论如何,要对用户系统进行基准测试以动态更改画布实验(或任何内容),以便将其优化为所述特定用户。

EDIT: This might possibly be the best solution: http://benchmarkjs.com/ 编辑:这可能是最好的解决方案: http//benchmarkjs.com/

Measure the time it takes to render a few frames of whatever you're doing and adjust the level of detail accordingly. 测量渲染几帧所需的时间,并相应地调整细节级别。 If you don't mind the details changing on the fly, you could use continuous measuring. 如果您不介意动态更改细节,可以使用连续测量。

What you don't want to do is make your user sit through a five-minute benchmark before they can do anything with your thing. 什么你不想做的就是让你的用户通过坐五分钟的基准,然后才能与你的事做任何事情。

FutureMark's Peacekeeper Benchmark pretty much does this already. FutureMark的Peacekeeper Benchmark已经做到了这一点。 I think it tests a few other things too, but it does heavy canvas benchmarking as well. 我认为它也会测试其他一些东西,但它也会进行大量的画布基准测试。

I suppose you could devise some sort of a benchmark which measures the framerate on the canvas for the user and then adjusts details based on that. 我想你可以设计某种基准测试,测量用户在画布上的帧速率,然后根据它调整细节。 This could be accomplished by setting a short interval and rendering things on the canvas, then using Date objects on each iteration to time how long it took and calculating an average framerate based on that. 这可以通过设置一个短间隔并在画布上渲染事物,然后在每次迭代时使用Date对象来计算所花费的时间并基于此计算平均帧速率来实现。

EDIT: Whoops... read the question too fast. 编辑:哎呀......读得太快了。 My answer doesn't really apply. 我的回答并不适用。


Depends on the level of accuracy you want. 取决于您想要的准确度。

If you don't want something super accurate, it may be possible with a bit of work. 如果你不想要超精确的东西,可能需要做一些工作。

The way I see it; 我看待它的方式; one of your biggest problems will be taking into account the various JS engines in different browsers, and metering everyone according to that specific browser and engine's baseline. 您最大的问题之一是考虑不同浏览器中的各种JS引擎,并根据特定浏览器和引擎的基线计量每个人。

For example, try running any SunSpider test on IE 5.5 then on Google Chrome on the same machine... amazing difference. 例如,尝试在IE 5.5上运行任何SunSpider测试,然后在同一台计算机上的Google Chrome上运行...惊人的差异。 You'll have to take that into account. 你必须考虑到这一点。 http://www.webkit.org/perf/sunspider/sunspider.html http://www.webkit.org/perf/sunspider/sunspider.html

Ideally, you'd want to correlate scores between different browsers as well (ie. this test runs in x ms on machine A in IE 6, and in y ms on the same machine in IE 8, so I can correlate IE 6 scores to IE 8 scores by using the average factor different). 理想情况下,您也希望关联不同浏览器之间的分数(即,此测试在IE 6中的机器A上以x ms运行,在IE 8中在同一台机器上以y ms运行,因此我可以将IE 6分数与IE 8通过使用不同的平均因子得分。 It might be hard to get a large enough sample size of data to do an effective job. 可能很难获得足够大的数据样本量来完成有效的工作。

Should be pretty simple. 应该很简单。 Just keep a frame counter and elapsed time in whatever function updates your canvas and divide the former by the latter to get FPS. 只需保留一个帧计数器和经过的时间,无论什么功能更新您的画布,并将前者除以后者以获得FPS。 You can scale down the number of particles/samples/etc. 您可以缩小粒子数/样本数等。 dynamically based off of the FPS. 动态地基于FPS。 So basically--yes, but it's totally custom. 所以基本上 - 是的,但它完全是定制的。

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

相关问题 是否可以使用JavaScript从浏览器中检索用户的主页URL? - Is it possible to retrieve a user's homepage URL from the browser with JavaScript? 是否可以将javascript代码安全地发送到用户的浏览器? - Is it possible to send javascript code to a user's browser securely? 用户可以在浏览器中修改站点javascript吗? - Is it possible for a user to modify site javascript in browser? 是否可以触发文件下载到用户的浏览器? - Is it possible to trigger file download to a user's browser? 是否可以使用javascript测试用户的浏览器/操作系统是否支持给定类型的链接? - Is it possible to test whether a user's browser/OS supports a given type of link using javascript? 是否可以通过 JavaScript 中的浏览器确定操作系统中设置的用户区域设置的**国家/地区**? - Is it possible to determine the user locale's **country** as set in the OS from the browser in JavaScript? 是否可以使用Javascript触发浏览器的About窗口? - Is it possible to fire a browser's about window with Javascript? Javascript —检测用户浏览器的可视区域 - Javascript — Detect Viewable Area of a User's Browser 是否可以使用javascript从浏览器中的sd卡读取文件系统 - Is it possible to read file system from sd card in browser using javascript 是否可以在 Javascript 中取消静音用户的计算机? - Is it possible to unmute the user's computer in Javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM