which is faster (a repeat structure question)
Richard Gaskin
ambassador at fourthworld.com
Thu Sep 26 04:05:01 EDT 2002
Shao Sean wrote:
>> put url("file:"&it) into inputData
> you store the data
>
>> replace numToChar(i) with ("=" & toUpper(baseConvert(i,10,16))) \
>> in inputData
> you convert the data
>
>
>> -- TEST 2
> but for test2 the data is still converted..
Good catch. I revised it as shown below and still get similar results.
Oddly enough, on files containg binary data the outputs do not match.
Should they?
on mouseUp
answer file "Select a file:"
if it is empty then exit to top
put url("file:"&it) into inputData1
put inputData1 into inputData2
put len(inputData1) into tLen
set the cursor to watch
--
-- TEST 1
--
put the milliseconds into tStart
repeat with i = 127 to 255
replace numToChar(i) with ("=" & toUpper(baseConvert(i,10,16))) \
in inputData1
end repeat
put the milliseconds - tStart into tTime1
put inputData1 into tOut1
--
-- TEST 2
--
put the milliseconds into tStart
repeat for each char inputDataChar in inputData2
if (charToNum(inputDataChar) >= 127) then
put "=" & toUpper(baseConvert(charToNum(inputDataChar),10,16)) \
after outputData
else
put inputDataChar after outputData
end if
end repeat
put the milliseconds - tStart into tTime2
put outputData into tOut2
--
-- RESULTS
--
if tOut1 <> tOut2 then put "error in one of the algorithms"
else put "Length: "&tLen&" replace: "&tTime1 &\
" repeat for each: "& tTime2
end mouseUp
--
Richard Gaskin
Fourth World Media Corporation
Custom Software and Web Development for All Major Platforms
Developer of WebMerge 2.0: Publish any database on any site
___________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
Tel: 323-225-3717 AIM: FourthWorldInc
More information about the metacard
mailing list