Skip to content

Instantly share code, notes, and snippets.

@dockimbel
Last active March 5, 2026 15:28
Show Gist options
  • Select an option

  • Save dockimbel/9fb619c9f0fadbfc52b549e131dd8982 to your computer and use it in GitHub Desktop.

Select an option

Save dockimbel/9fb619c9f0fadbfc52b549e131dd8982 to your computer and use it in GitHub Desktop.
Performance testing on INSERT/APPEND on strings
Red []
recycle/off
s: make string! 20e6
clear s
append s "hello"
recycle
mem0: stats
clock [ loop 1e5 [insert s [1 3.14 (1.0, 2,0)]] ]
print ["mem:" stats - mem0]
clear s
append s "hello"
recycle
mem0: stats
clock [ insert/dup s [1 3.14 (1.0, 2,0)] to-integer 1e6]
print ["mem:" stats - mem0]
clear s
recycle
mem0: stats
clock [ loop 1e6 [insert tail s [1 3.14 (1.0, 2,0)]] ]
print ["mem:" stats - mem0]
clear s
recycle
mem0: stats
clock [ insert/dup tail s [1 3.14 (1.0, 2,0)] to-integer 1e6]
print ["mem:" stats - mem0]
clear s
append s "hello"
recycle
mem0: stats
clock [ loop 1e4 [insert s [<div><i><b> Hello </b></i><u> World! </u></div>] ]]
print ["mem:" stats - mem0]
clear s
append s "hello"
recycle
mem0: stats
clock [ loop 1e5 [append s [1 3.14 (1.0, 2,0)]] ]
print ["mem:" stats - mem0]
clear s
append s "hello"
recycle
mem0: stats
clock [ append/dup s [1 3.14 (1.0, 2,0)] to-integer 1e6]
print ["mem:" stats - mem0]
clear s
recycle
mem0: stats
clock [ loop 1e6 [append s [1 3.14 (1.0, 2,0)]] ]
print ["mem:" stats - mem0]
clear s
recycle
mem0: stats
clock [ append/dup s [1 3.14 (1.0, 2,0)] to-integer 1e6]
print ["mem:" stats - mem0]
clear s
append s "hello"
recycle
mem0: stats
clock [ loop 1e4 [append s [<div><i><b> Hello </b></i><u> World! </u></div>] ]]
print ["mem:" stats - mem0]
@hiiamboris
Copy link

should be recycle/off ? ;)

@hiiamboris
Copy link

otherwise RAM waste is 2x underreported :)

@dockimbel
Copy link
Author

Good catch! recycle off is Rebol2 syntax... Hard to get rid of old habits...

Fixed in the above code now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment