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

[REBOL] Re: Buffers

From: brett::codeconscious::com at: 14-Feb-2001 12:23

I believe it preallocates memory thus avoiding the costs of automatic expansion of storage. Try this: REBOL [ Author: "Brett Handley" Title: "Memory allocation test" ] max-count: 100000 prealloc-results: copy [] noalloc-results: copy [] for test 1 5 1 [ a: now/time/precise test-string: make string! 0 for i 1 max-count 1 [insert tail test-string "BlahBlah"] b: now/time/precise append noalloc-results probe subtract b a a: now/time/precise test-string: make string! 500000 for i 1 max-count 1 [insert tail test-string "BlahBlah"] b: now/time/precise append prealloc-results probe subtract b a ] print "Unallocated Results" print mold noalloc-results print "Preallocated Results" print mold prealloc-results Brett.