New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsecond resolution of performance.now() and Stopwatch #9565
Comments
This comment was originally written by @bp74 Maybe it's important to add that this is on a Windows 7 64 bit machine. |
This comment was originally written by @bp74 Okay i did some more tests, dependent on the browser you get different results: IE 9: error because performance.now() does not exist. So only IE10 and Firefox 19 work as expected (on Windows 7) but not WebKit browsers. |
Not quite sure I follow- I'm seeing window.performance.now as microseconds in all supported cases. Is the request that Stopwatch use window.performance.now in dart2js when possible? |
This comment was originally written by @bp74 If you call window.performance.now() several times, you get this times: the now() function should give you milliseconds but with a microsecond resolution. The problem is that it does not give you the fraction of the millisecond. The fraction is always 000 or 999. The same happens with a Stopwatch. The Stopwatch class has a "microseconds" property, but the value is always a multiple of 1000. |
This comment was originally written by @bp74 Here is another example to make it clearer: import 'dart:html'; If you continuously click on the document, you get this result: 1032.999999995809 window.performance.now() should give you milliseconds, but the fraction should give you microseconds. |
I'm able to repro this on Chrome Windows, but not Linux. I assume it's running into this Chrome bug https://code.google.com/p/chromium/issues/detail?id=158234 Resolving as 'As Designed' as I believe the Dart functionality is performing properly, but it's limited by the underlying Chrome implementation. Added AsDesigned label. |
FWIW it seems like windows.performance.now() works better on Mac: 7781.259999999747 |
This comment was originally written by Misko.H...@gmail.com pete> Is the request that Stopwatch use window.performance.now in dart2js when possible? Yes, I think that is the request. We should be using high resolution timer whenever possible. |
Stopwatch does use window.performance.now when available (all but Safari). |
This issue was originally filed by @bp74
What steps will reproduce the problem?
I think this is more a Dartium bug, but still ...
import 'dart:html';
void main() {
var sw = new Stopwatch()..start();
var pn = window.performance.now();
for(int i = 0; i< 100000; i++);
var d1 = sw.elapsedMicroseconds;
var d2 = 1000 * (window.performance.now() - pn);
print(d1);
print(d2);
}
What is the expected output? What do you see instead?
You get microseconds, but the resolution is milliseconds. So it doesn't make much sense. This little program prints:
1000
999.9999999763531
What version of the product are you using? On what operating system?
Dart Editor version 0.1.2_r20718
Dart SDK version 0.1.2.0_r20702
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: