Closed Bug 661130 Opened 13 years ago Closed 13 years ago

setTimeout can't do 5ms

Categories

(Core :: DOM: Core & HTML, defect)

1.9.1 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: noitidart, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19

It does like 50ms etc. I have an i7 but i get 6ms pause closest, maybe 1 out of 5 tries.

Reproducible: Always

Steps to Reproduce:
1. Paste this code:
<html>
<body>

<script type="text/javascript">

var start = new Date();
setTimeout(function(){
var end = new Date();
document.write(end.getTime() - start.getTime());
},5);

</script>

</body>
</html>

Actual Results:  
Takes up to 50ms.

Expected Results:  
Should take 5ms.
The default timer resolution in the Windows operating system is 15.6 ms, and that may be one reason it's hard to reliably achieve short timeouts. And Windows is not a real time operating system, so there is no warranty that you get the timeout you ask for.

Your User-Agent string says you are running Firefox 3.5.19. Does it make any difference it you try a modern browser like Firefox 4.0.1?
https://www.mozilla.com/en-US/firefox/all.html

Works for me. Most of the time 5 ms, sometimes 4 ms, sometimes 6 ms, and sometimes just a little bit more, with AMD Phenom(tm) II X4 955 Processor.
Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Mozilla/5.0 (X11; Linux x86_64; rv:7.0a1) Gecko/20110531 Firefox/7.0a1

Works for me somewhat, but the times varies between 9 and 11 ms, and most of the time I get 10 ms.
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19

Apparently, under Linux a modern Firefox performs better.
Version: unspecified → 3.5 Branch
Oh I didn't test it in FF4. Let me do that and get back to you. Currently I have 3.5 installed as I am testing my extension on it.
Are bugs still being fixed for 3.5.x. Do you think this would be a bug for it? I didn't know it was OS dependent.

I just tried it out in the latest chrome and WOW big high 5 to firefox, even its older version (3.5.19) outperforms it. Chrome is giving me minimum values from 150-190.

1 out of like 15 is 55.

[love FF, at least we're beating chrome somewhere! :)]
Firefox 3.5 will soon be declared obsolete. Actually it's already living overtime.
https://wiki.mozilla.org/Releases/3.5_EOL

And only security and stability fixes are done in Firefox 3.6, so Firefox 4 or later is the way to go. Firefox 7 is where the development happens today.

BTW, I've tested Chromium and I get 6 ms most of the time.
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.71 Safari/534.24
There are some subtle complexities here, but I think this is basically working as expected. See also https://developer.mozilla.org/En/Window.setTimeout
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Resolution: --- → INVALID
Version: 3.5 Branch → 1.9.1 Branch
Ok thanks all, so sorry about this report.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.