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

发布于 2024-11-17 13:35:38 字数 274 浏览 0 评论 0原文

随着 Html5 开始普及,我们看到更多关于视频或画布元素等的实验。

当使用画布进行实验时,例如用粒子制作烟花,1000 个粒子可能在现代机器上运行良好,但在 3 年机器上可能会运行得很慢。

无论如何,是否可以对用户系统进行基准测试以动态更改画布实验(或任何内容),以便针对所述特定用户对其进行优化。

编辑:这可能是最好的解决方案: http://benchmarkjs.com/

As Html5 starts gaining ground, we are seeing more experiments with things like the video or canvas element.

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.

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/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜光 2024-11-24 13:35:38

测量渲染您正在做的任何事情的几帧所需的时间,并相应地调整细节级别。如果您不介意动态更改细节,则可以使用连续测量。

不想要做的是让您的用户在可以对您的产品进行任何操作之前先完成五分钟的基准测试。

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.

你的呼吸 2024-11-24 13:35:38

FutureMark 的 Peacekeeper Benchmark 几乎已经做到了这一点。我认为它还测试了其他一些东西,但它也进行了大量的画布基准测试。

我想您可以设计某种基准来测量用户画布上的帧速率,然后根据该基准调整细节。这可以通过设置较短的间隔并在画布上渲染内容,然后在每次迭代中使用 Date 对象来计算所花费的时间并据此计算平均帧速率来完成。

FutureMark's Peacekeeper Benchmark pretty much does this already. 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.

爱要勇敢去追 2024-11-24 13:35:38

应该很简单。只需在更新画布的任何函数中保留帧计数器和经过的时间,并将前者除以后者即可获得 FPS。您可以缩小粒子/样本/等的数量。动态地基于 FPS。所以基本上——是的,但这完全是定制的。

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. You can scale down the number of particles/samples/etc. dynamically based off of the FPS. So basically--yes, but it's totally custom.

番薯 2024-11-24 13:35:38

编辑:哎呀...读问题太快了。我的答案并不真正适用。


取决于您想要的准确度。

如果您不想要超级精确的东西,可能需要做一些工作。

我的看法是;最大的问题之一是考虑不同浏览器中的各种 JS 引擎,并根据特定浏览器和引擎的基线来衡量每个人。

例如,尝试在同一台机器上的 IE 5.5 上运行任何 SunSpider 测试,然后在 Google Chrome 上运行...惊人的差异。你必须考虑到这一点。 http://www.webkit.org/perf/sunspider/sunspider.html

理想情况下,您还希望关联不同浏览器之间的分数(即,此测试在 IE 6 中的计算机 A 上运行 x 毫秒,在 IE 8 中的同一计算机上运行 y 毫秒,所以我可以使用不同的平均因子将 IE 6 分数与 IE 8 分数关联起来)。可能很难获得足够大的数据样本来完成有效的工作。

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.

For example, try running any SunSpider test on IE 5.5 then on Google Chrome on the same machine... amazing difference. You'll have to take that into account. 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). It might be hard to get a large enough sample size of data to do an effective job.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文