Wed, Oct 21, 2009 8:34 AM
For questions about the relative performance of different ways of solving a problem, it's often faster to just test it than it is to post to the list and wait for a reply.
This is also helpful because you'll know first-hand exactly which one performs better, and can tweak your tests to refine them further if needed.
Also, as a bit of a benchmarking geek I've found that results will often vary according to the data you're working with. For example, one common rule of thumb is that arrays are always faster for accessing data elements than chunk expressions, but having looked into this in detail I've found that's not always true depending on the specifics of the task at hand (I'll get into that more later, as some of the results were rather surprising but ultimately understandable).
Here's a simple script you can use as a template for benchmarking relative performance - just put this in a button, add whatever code you want to test in the two places noted, and click:
on mouseUp -- Many tasks are so quick they don't show a measurable -- difference unless they're run multiple times, so we -- run through the number of iterations specified here: put 1000 into tIterations -- -- TEST 1: put the millisecs into t repeat tIterations -- Do one test here: end repeat put the millisecs - t into t1 -- -- TEST 2: put the millisecs into t repeat tIterations -- Do comparative test here: end repeat put the millisecs - t into t2 -- -- DISPLAY RESULTS: put t1 && t2 end mouseUp
Note that tIterations is set to 1000 in this script, but depending on what you want to do that may be too small. For some tests I bump it up to 10000; that's why I have it on a separate line, so it's easy to change when needed.
Another way to test these sorts of things is with RevBench, a free tool available in the Stacks section of RevNet.
In Rev, see Development->Plugins->GoRevNet
RevBench provides a simple but convenient way to run two script snippets to see which is faster. Lately some of the benchmarking I do is too complex to fit into that setup so I tend to use the script I posted above, but for simple tests RevBench can be handy.
Blog Home Filed under: RunRev FAQ performance
|
Richard Gaskin
Ambassador, Fourth World
Netbook market on the rise
RunRev Complies with Jobs' Request, Moves Toward Android
Apple Snubs OS X at WWDC
Moment of Zen
Apple's new SDK license locks iPhone out of the HLL revolution
Scripting Style Guide Updated
Agile Manifesto
Bugs in Rev: a little perspective
New Rev-centric Linux Distro
Crystal ball time
Too tall to live, too weird to die
Oracle, Sun, and the future of MySQL
RevWeb security warnings: use sparingly
Installers making a comeback on Mac?
"Rev Message Path" article updated
Your Windows 7 Launch Party
Smartphone competition - at last
Benchmarking performance
New Interviews at revJournal: Jerry and Andre
Windows 7 HIG: time to say goodbye to XP?
agile (1)
Apple weirdness (2)
best practices (2)
community (1)
databases (1)
fluff (2)
games (2)
HyperCard (1)
iPad (3)
iPhone (1)
irony (1)
linux (1)
marketing (6)
mobile (1)
netbooks (1)
performance (1)
predictions (1)
rant (2)
RevMobile (1)
RunRev FAQ (5)
scripting style (1)
server (1)
UI (1)
usability (6)
RunRev.com
Sarah's Rev Blog
Björnke's Stacks Blog
theWorcesterSource
Releasable Rev Blog
RevEditor (tRev) Blog
Chipp Walters 'Rev Blog
WeCode Planet

|