Skip to content

Instantly share code, notes, and snippets.

@ThierryGoubier
Last active December 8, 2015 09:59
Show Gist options
  • Save ThierryGoubier/a3193bd18aea8d20f4af to your computer and use it in GitHub Desktop.
Save ThierryGoubier/a3193bd18aea8d20f4af to your computer and use it in GitHub Desktop.
Morphic Performance Testing
"Morphic Performance Testing v2"
| rand creating deleting hiding showing ellipses |
rand := Random new.
creating :=
[ | m | m := EllipseMorph new.
ellipses add: m.
m color: Color random.
m position: ActiveWorld extent * ((rand next)@(rand next))
].
deleting := [ World removeAllMorphsIn: ellipses].
hiding := [ ellipses do: [ :item | item hide ] ].
showing := [ ellipses do: [ :item | item show ] ].
Transcript show: 'Morphic Performance Test Code v3.0 - ##FLAVOUR## '; cr.
Transcript show: 'amount, createTime, createRefreshTime, hideTime, hideRefreshTime, showTime, showRefreshTime, deleteTime'; cr.
#( 1 10 100 200 300 400 500 600 700 800 900 1000 2000
3000 4000 5000 6000 7000 8000 9000 10000 30000 100000)
do: [ :amount | | createTime cTOneCycle hideTime hTOneCycle showTime sTOneCycle deleteTime |
ActiveWorld doOneCycle.
ellipses := OrderedCollection new: amount.
createTime := [ amount timesRepeat: creating.
World addAllMorphs: ellipses.
] timeToRun asMilliSeconds.
cTOneCycle := [ ActiveWorld doOneCycle ] timeToRun asMilliSeconds.
hideTime := [ hiding value ] timeToRun asMilliSeconds.
hTOneCycle := [ ActiveWorld doOneCycle ] timeToRun asMilliSeconds.
showTime := [ showing value ] timeToRun asMilliSeconds.
sTOneCycle := [ ActiveWorld doOneCycle ] timeToRun asMilliSeconds.
deleteTime := [ deleting value ] timeToRun asMilliSeconds.
Transcript show: amount asString, ' ',
createTime asString, ' ',
cTOneCycle asString, ' ',
hideTime asString, ' ',
hTOneCycle asString, ' ',
showTime asString, ' ',
sTOneCycle asString, ' ',
deleteTime asString; cr.
]
@ThierryGoubier
Copy link
Author

Performance is linear with the number of morphs. Time is in ms.

Original script from Ben Coman: http://blog.openinworld.com/2011/03/morphic-performance/

amount createTime hideTime showTime deleteTime
100000 1820 501 469 342

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