I came across this as I was trying to generate a string of 1,000,000 random ASCII characters (in the ASCII 65 TO 90 range). My idea was to generate one random character at a time, and then keep concatenating the results into one, long string.
For this test, I eliminated the RND segment and used the following code that simply adds the character "A" in varying iterations...
----------------------------------
Take note of the striking drop in processing speed after the 300,000th
iteration.
My workaround was to split the processing into fewer iterations (say, 10,000 iterations x 100) and then concatenate the 100 separate strings into the final long string.
Is this relative increase in processing time caused by the increasing length of the contents of PanString$ ? Or could this be attributable to something else? I'd appreciate any feedback.
For this test, I eliminated the RND segment and used the following code that simply adds the character "A" in varying iterations...
----------------------------------
Code:
#COMPILE EXE #DIM ALL GLOBAL PanString$ GLOBAL Start# GLOBAL Finish# GLOBAL Counter& FUNCTION PBMAIN () AS LONG Start# = TIMER FOR Counter& = 1 TO 100000 Panstring$ = Panstring$ + "A" NEXT Counter& BEEP Finish# = TIMER PRINT "ELAPSED TIME=";Finish#-Start# WAITKEY$ END FUNCTION --------------------------------------------- Using my old 2.6GHz PC, and my PBCC Version 4.04.042, I got these results: ITERATIONS SECONDS ------------- ---------------- 100,000 1.828 150,000 4.186 200,000 7.188 250,000 15.360 300,000 39.297 400,000 141.530
iteration.
My workaround was to split the processing into fewer iterations (say, 10,000 iterations x 100) and then concatenate the 100 separate strings into the final long string.
Is this relative increase in processing time caused by the increasing length of the contents of PanString$ ? Or could this be attributable to something else? I'd appreciate any feedback.
Comment