Adobe, MAKE SOME NOISE

UPDATE: I've written an updated version of this code that uses some automated averaging and outputs the performance visually for testing the release player inside browser conditions. Speed Benchmark II

This test harness repeats the same code over and over again (one million times) in order to get a better average of how long a given piece of code takes to execute. This should be run from the timeline in an otherwise empty fla. Although the default is set to 1,000,000 iterations, it's a good idea to start as low as 1,000 iterations to avoid timeouts or crashes from heavy or complex code – use at your own risk!

  1. // www.calypso88.com
  2.  
  3. var _startMem:int = System.totalMemory;
  4. var _startTime:int = getTimer();
  5.  
  6. var i:int = 1000000;
  7.  
  8. while(i){
  9. i += -1;
  10.  
  11. // test code goes here
  12. }
  13.  
  14. var _maxTime:int = getTimer() - _startTime;
  15. var _endMem:int = System.totalMemory;
  16.  
  17. trace('Memory: ', _startMem/1024/1024, 'mb => ', _endMem/1024/1024, 'mb');
  18. trace('Time: ', _maxTime, 'ms');

Leave a Reply