Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: New competition: do you accept the challenge?! :-)

From: petr:krenzelok:seznam:cz at: 7-Nov-2007 0:06

My machine shows 15 sec in R2. 12 after following optimisations: rebol [] print "START..." s1: now str: make string! 5000 finale: make string! 50000 j: 0 repeat i 10000 [ clear str loop 500 [ j: j + 1 insert tail str reduce [i #"," j #"-"] ] insert tail finale copy/part next str 4 ] print "STOP!" print length? finale print (now/time - s1/time) halt Just chatted with Carl on r3 world and some of his suggestions: - The line: repeat j 500 [] is very expensive inside a repeat 10000. - Because, repeat must deep copy and rebind its body block 10000 times. - You may want to try a LOOP 500, with just a normal ++ j in there instead. - Also, [i #"," j #"-"] is faster -- but may not be that much faster. - skip str 1 --> next str - Otherwise, seems to look good. Cheers, -pekr-