JavaScript:如何确定运行时(又名浏览器)的性能? [英] JavaScript: How to determine performance of the runtime (aka browser)?
问题描述
我有一个JavaScript应用程序,可以正常运行,但肯定需要一些内存/CPU性能(基于Google地图).
I have a JavaScript application, which works fine, but certainly needs some memory / CPU performance (it is based on top of Google maps).
因此,基本上,它可以在台式机/笔记本电脑上正常运行,iPad可以正常工作.但是,当今使用所有这些不同的设备,小型设备肯定超载了.
So basically it runs fine on a Desktop / Laptop PC, iPad works OK. But with all these different devices nowadays, smaller devices are definitely overloaded.
因此,基本上,我想确定可用的运行时,并决定是否启动我的JavaScript应用程序,或显示一条消息.
So basically I want to determine the available runtime and decide whether I start my JavaScript application, or display a message instead.
- 好的,我可以检查浏览器,但这是一个永无止境的故事
- 我可以检查操作系统信息,但这又是非常乏味的.此外,某些操作系统还可以在高性能设备和低端硬件上运行.
- 我可以检查屏幕尺寸并排除手机,但随后变得困难
那么有没有一种方法可以确定客户端的性能?为了明确起见,我不在乎它是否是平板电脑,但是如果它是性能低下的平板电脑,很少的CPU性能/内存(因此使用javascript检测phone/tablet/web客户端没有帮助).
So is there a way to determine the performance of the client? Just to make it clear, I do not care whether it is a tablet for instance, but if it is a low performance tablet with little CPU performance / memory (so Detect phone/tablet/web client using javascript does not help).
推荐答案
在javascript中,您可以检查功能列表,并在设备内存不足的情况下得出结论.
In javascript You could check list of features and based on that do conclusion if device is low memory.
例如:
-
使用window.navigator.hardwareConcurrency检查核心计数(为获得更好的覆盖范围,请添加 Core Estimator polyfill )
检查WebGL支持(我喜欢user2070775的建议):正确的检测方法WebGL支持吗?
Check WebGL support (I like user2070775 suggestion): Proper way to detect WebGL support?
检查其桌面设备还是移动设备.很有可能台式机的内存不会有任何问题.
Check if its desktop or mobile. Most likely desktop will not have any problems with memory.
检查屏幕分辨率-最有可能的小分辨率将出现在低内存设备上.
Check resolution of screen - most likely small resolution will be on low memory devices.
这篇关于JavaScript:如何确定运行时(又名浏览器)的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!