On Thursday, June 19, 2003, at 12:15 AM, Dar Scott wrote:
On Wednesday, June 18, 2003, at 11:08 PM, Chipp Walters wrote:
I'm with Jacqueline. I always thought it took the interpreter longer to
figure out what it's looking at.
_HyperTalk 2.2 The Book_
Says on p. 45. "Enclosing literals in quotation marks can result in considerable time savings-- up to 20% for loops with several hundred or thousand repetitions."
A quick test on OS X seems to indicate that is not the case:
on mouseUp
local x
set the numberFormat to "0.000000"
put empty into field "Report"
put the long seconds into tEnd -- throw this one away
put the long seconds into tStart
put the long seconds into tEnd
put tEnd-tStart into tCorrection
put the long seconds into tStart
put the highlight of button "dummy" into x
put the long seconds into tEnd
put (tEnd - tStart - tCorrection) & " s quoted" & LF after field "Report"
put the long seconds into tStart
put the highlight of button dummy into x
put the long seconds into tEnd
put (tEnd - tStart - tCorrection) & " s unquoted" & LF after field "Report"
end mouseUp
In this test you are accessing a UI object. I suspect that access is going to skew things. We know accessing fields is much slower than accessing variables... maybe the same with for buttons?
But I ran my own test and can't discern any noticeable difference. Sometimes quoted literals is faster, sometimes unquoted literals is faster. The Hypertalk Book is so clear about this. Maybe we are not writing correct benchmarks?
on mouseup
set the cursor to clock
set the numberFormat to "0.000000"
put pi into tArr["valOfPI"]
put empty into tStart
put empty into tEnd
--
-- with quoted literal
--
put the long seconds into tStart
repeat for 1000000
get tArr["valOfPI"]
end repeat
put the long seconds into tEnd
put tEnd-tStart into tCorrection1
put "with quoted literal"&& tab & tCorrection1 & \
linefeed after fld "Report"
--
-- without quoted literal
--
put the long seconds into tStart
repeat for 1000000
get tArr[valOfPI]
end repeat
put the long seconds into tEnd
put tEnd-tStart into tCorrection2
put "without quoted literal"&& tab & tCorrection2 & \
linefeed after fld "Report"
--
-- difference
--
put (tCorrection1 / tCorrection2) * 100 & \
"%" & linefeed after fld "Report"
end mouseup
Alex Rice, Software Developer Architectural Research Consultants, Inc. http://ARCplanning.com
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
