用于创建具有高时间precision桌面上对时间敏感的应用程序的浏览器最好的方法? [英] Best approach for creating a time sensitive browser app for desktop with high time precision?

查看:73
本文介绍了用于创建具有高时间precision桌面上对时间敏感的应用程序的浏览器最好的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不开发将需要一系列的实验中测量用户响应时间的应用程序。此应用程序将运行在大约100台计算机,因此,我曾提到,基于浏览器的方法可能是最好的,以减少执行安装和更新。随着中说,现在,我读过有关定时器的浏览器的准确度,特别是JavaScript的计时器,我学习也可以从几毫秒向上10-15ms的延迟。这种延迟可能对这些实验的precision产生负面影响,当用户测量它们的响应时间在屏幕上的视觉队列。

I have to develop an application that will be required to measure user response time within a series of experiments. This application will be run on approximately 100 computers, thus I had mentioned that a browser based approach might be best to cut down on performing installs and updates. With that said, now that I've read about the accuracy of timers in browsers, specifically javascript timers, I'm learning there can be a delay from a few milliseconds to upwards of 10-15ms. This sort of delay would have a negative impact on the precision of these experiments when users measure their response time to visual queues on the screen.

有没有解决这个已知的方式来获得一个Web应用程序precise定时器正在通过JavaScript的浏览器中运行?同样,有些实验需要简单的2D动画,比如看到,用户可以保持多长时间的鼠标光标放在一个旋转的立方体。我想preFER使用HTML5和Javascript,我们不能使用闪光灯。

Is there a known way around this to get precise timers for a web application being run within a browser through javascript? Likewise, some of these experiments require simple 2d animation, such as seeing how long a user can keep their mouse cursor over a rotating cube. I would prefer to use HTML5 and Javascript and we cannot use flash.

推荐答案

true,则无法依靠定时器的时间间隔,但你可以依靠一个新的Date对象。例如:

True you can't rely on a timer's interval, but you can rely on a new Date object. For instance:

var previousTime = new Date().getTime(); // returns milliseconds of "now"

var timer = setInterval( function() {
   var currentTime = new Date().getTime();
   var millisecondsSinceLastUpdate = currentTime - previousTime;
   previousTime = currentTime;
   alert( 'milliseconds since last update: ' + millisecondsSinceLastUpdate );
}, 1 );

这篇关于用于创建具有高时间precision桌面上对时间敏感的应用程序的浏览器最好的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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