Jump to content

convert Array without PCM loop


---
 Share

Recommended Posts

It's not only the loops fault for being slow but PCM is poor at handeling long strings. As TextVar1 grow with each itteration the time it takes to add another line to it also grows. In the end you have and exponential growth in the time it takes for each line. I usually solve this by creating a temporary string that loads of to the primary string at given intervals. How often depends on how long the rows are. You can play around with it by altering the denominator in the mod()-function.
With this method I got it down from 11 to 3 seconds (your cumputer could use and upgrade I think).
Still smalltalk is ofcourse faster but also harder for people to understand unless they know smalltalk.

nP = 3600
rad=10

TimeStart=millisecondClockValue()
TextVar1 =""
TextVar1temp =""
for n = 0 to nP
TextVar1temp =TextVar1temp + formatR(cos(n/0.1)*rad ,0,10)+ "    " + formatR(sin(n/0.1)*rad ,0,10)+ "    " +  formatR(0 ,0,10) + "    " + formatR(cos(n/0.1) ,0,10)+ "    " + formatR(sin(n/0.1),0,10)+ "    " +  formatR(0 ,0,10) +cr()
	if mod(n,50) == 0
		TextVar1 = TextVar1 + TextVar1temp
		TextVar1temp =""
	endif
next n
TextVar1 = TextVar1 + TextVar1temp
display("Generation of points PCMLOOP:   "  +  (millisecondClockValue() -TimeStart)  + " milliSeconds")


TimeStart=millisecondClockValue()
code="newString:= WriteStream on: String new. 0 to: " + nP  + " do:[:n|newString nextPutAll: "
code= code + " ((((n/0.1) asRAD cos) * " +  rad +  ") asStringWithDigits: 10)  , Character tab asString , "
code= code + " ((((n/0.1) asRAD sin) * " +  rad +  ") asStringWithDigits: 10)  , Character tab asString,  "
code= code + " '0.0000000000'  , Character tab asString ,  "
code= code + " (((n/0.1) asRAD cos ) asStringWithDigits: 10)  , Character tab asString , "
code= code + " (((n/0.1) asRAD sin ) asStringWithDigits: 10)  , Character tab asString ,  "
code= code + " '0.0000000000'  , Character tab asString  "
code= code + "; cr ] . ^newString contents."

TextVar2=executeCode(code)
display("Generation of points WriteStream:   "  +  (millisecondClockValue() -TimeStart)  + " milliSeconds")
Link to comment
Share on other sites

Please sign in to view this quote.


🤣 I’m also using similar solutions...
Something funny about the performance of the computer is that most of the day I work with a low performance laptop because I don't like to hear the workstation fan ..
Link to comment
Share on other sites

 Share

×
×
  • Create New...