Skip to content

Instantly share code, notes, and snippets.

@hiiamboris
Created March 30, 2018 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiiamboris/91f1dd05058b6c1eb7d0299befd34bde to your computer and use it in GitHub Desktop.
Save hiiamboris/91f1dd05058b6c1eb7d0299befd34bde to your computer and use it in GitHub Desktop.
Red []
clock: func [code /local t1 t2] [
t1: now/precise/time
loop 100 code
t2: now/precise/time
print [(t2 - t1) mold/flat code]
]
m1: #()
m2: #()
m3: #()
m4: #()
m5: #()
repeat i 10000 [
put m1 (rejoin ["s" i]) i
put m2 (to-word rejoin ["wordwordwordwordwordword" i]) i
put m3 i i
put m4 rejoin ["" i " string string string string " i] i
put m5 rejoin ["somestring somestring somestring " i] i
]
subset: copy []
loop 100 [append subset random 10000]
chosen1: copy [] foreach n subset [append chosen1 rejoin ["s" n]]
chosen2: copy [] foreach n subset [append chosen2 to-word rejoin ["wordwordwordwordwordword" n]]
chosen3: copy [] foreach n subset [append chosen3 n]
chosen4: copy [] foreach n subset [append chosen4 rejoin ["" n " string string string string " n]]
chosen5: copy [] foreach n subset [append chosen5 rejoin ["somestring somestring somestring " n]]
probe reduce [
10000 = length? m1
10000 = length? m2
10000 = length? m3
10000 = length? m4
10000 = length? m5
100 = length? chosen1
100 = length? chosen2
100 = length? chosen3
100 = length? chosen4
100 = length? chosen5
]
clock [ foreach s chosen1 [select m1 s] ]
clock [ foreach w chosen2 [select m2 w] ]
clock [ foreach n chosen3 [select m3 n] ]
clock [ foreach s chosen4 [select m4 s] ]
clock [ foreach s chosen5 [select m5 s] ]
clock [ foreach n chosen3 [put m3 n n] ]
clock [ foreach s chosen5 [put m5 s s] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment