bobx24 (6) [Avatar] Offline
#1
Hi,

On chapter 18, you suggest to use this Javascript code "(new Date()).getTime()" to measure code timing.
On the Windows platform, this is a bad idea, because it is plagued with a resolution of about 15ms.
On the other hand, the Flah native function "geTimer()" offers a full 1 ms resolution on Windows.

You can use the following code fragment to evaluate a timing function :
<canvas debug="true" proxied="false">
_<view>
__<button onclick="parent.test()">Test</button>
__<method name="test"><![CDATA[ >
___var ot= 0;
___var dts= new Array();
___for (var i= 0; i< 20; ) {
____var t= getTimer();
____if (t!= ot) {
_____dts[i]= t- ot;
_____ot= t;
_____i++;
____}
___}
___for (var i= 0; i< 20; i++) {
____Debug.write("dt= "+ dts[i]+ '
');
___}
__]]></method>
_</view>
</canvas>

Note: I've replaced the tab character with _, because I don't know how to indent code in this forum.

Robert