On Saturday, October 25, 2003, at 11:15 AM, Dar Scott wrote:


A year ago I ran some tests that did some timing measurements that demonstrate a little about constants. I don't know if I have it around. Maybe I can reconstruct that. The behavior might not be the same today, anyway.

The button script below indicates that an unquoted numeral value for a constant is basically the same as a quoted numeral. The leading 0 shows up in the value.


As far as speed... The first use of any constant in arithmetic seems to have some overhead and maybe the first use of a particular constant. After that, the speed is about the same. I'm not completely happy with this test; I think there must be more revealing tests.

The second use is not as fast as a value forced to internal numeric form. I thought I had seen that it was for 1.1.1, but now think I was mistaken.

The script below gave me these results (typically):

Time is in microseconds.
script const unquoted-- first: 8.9 second: 2.5
script const quoted--   first: 3.0 second: 2.1
varible with 0 added--  first: 1.0 second: 1.5
First char of b: 0

Dar Scott




********************* constant a = "0111.000000000000000000000000000000000000000000000000000" constant b = 0222.000000000000000000000000000000000000000000000000000 local c

-- This timing needs OS X quality timing.
on mouseUp
  local x, y, d, timeEnd, timeStart, timeFix
  set numberFormat to ".0"
  put "Time is in microseconds." & LF into report
  wait .2 seconds
  put 0+333 into c -- set up variable as "constant"
  put 0+444 into d
  put the long seconds into timeEnd -- dummy
  put the long seconds into timeStart
  put the long seconds into timeEnd
  put timeEnd-timeStart into timeFix

put the long seconds into timeStart
put d+b into x
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*1000000 into timeFirst
put the long seconds into timeStart
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put d+b into y
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*100000 into timeSecond
put "script const unquoted--" & tab & "first: " & timeFirst after report
put " second: " & timeSecond & LF after report



put the long seconds into timeStart
put d+a into x
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*1000000 into timeFirst
put the long seconds into timeStart
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put d+a into y
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*100000 into timeSecond
put "script const quoted-- " & tab & "first: " & timeFirst after report
put " second: " & timeSecond & LF after report


put the long seconds into timeStart
put d+c into x
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*1000000 into timeFirst
put the long seconds into timeStart
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put d+c into y
put the long seconds into timeEnd
put (timeEnd-timeStart-timeFix)*100000 into timeSecond
put "varible with 0 added-- " & tab & "first: " & timeFirst after report
put " second: " & timeSecond & LF after report


put "First char of b:" && char 1 of b & LF after report

  put report
end mouseUp
************************************

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to