Last active
March 5, 2026 15:28
-
-
Save dockimbel/9fb619c9f0fadbfc52b549e131dd8982 to your computer and use it in GitHub Desktop.
Performance testing on INSERT/APPEND on strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] | |
otherwise RAM waste is 2x underreported :)
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
should be
recycle/off? ;)