From 9b7f0ea8ffc0327def837271d74ae93f871d88f9 Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Sun, 9 Dec 2012 20:13:17 -0800 Subject: [PATCH] updated .gitignore and added more performance tests around image cropping and scaling in order to understand the value of a SpriteSheet plugin --- .gitignore | 1 + tests/js/performanceTests.js | 66 ++++++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c5054d7f..da1ca550 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ jsdoc-toolkit dist tests/js/unitTests.js +analysis # Numerous always-ignore extensions *.diff diff --git a/tests/js/performanceTests.js b/tests/js/performanceTests.js index 6aad34ff..34f920ff 100644 --- a/tests/js/performanceTests.js +++ b/tests/js/performanceTests.js @@ -1,5 +1,5 @@ Test.Modules.PERFORMANCE = { - '*draw 1000 cropped images': function(containerId) { + 'draw 1000 cropped and scaled images': function(containerId) { var imageObj = new Image(); imageObj.onload = function() { var stage = new Kinetic.Stage({ @@ -25,13 +25,75 @@ Test.Modules.PERFORMANCE = { layer.add(darth); } + stage.add(layer); + endTimer('draw 1000 cropped and scaled images'); + + }; + imageObj.src = '../assets/darth-vader.jpg'; + }, + 'draw 1000 cropped images': function(containerId) { + var imageObj = new Image(); + imageObj.onload = function() { + var stage = new Kinetic.Stage({ + container: containerId, + width: 578, + height: 200 + }); + var layer = new Kinetic.Layer(); + + startTimer(); + for(var n = 0; n < 1000; n++) { + var darth = new Kinetic.Image({ + x: 200, + y: 75, + image: imageObj, + width: 53, + height: 37, + crop: [186, 211, 292 - 186, 285 - 211], + draggable: true + }); + + layer.add(darth); + } + stage.add(layer); endTimer('draw 1000 cropped images'); }; imageObj.src = '../assets/darth-vader.jpg'; }, - '*draw 1000 pre-processed cropped images': function(containerId) { + 'draw 1000 scaled images': function(containerId) { + var imageObj = new Image(); + imageObj.onload = function() { + var stage = new Kinetic.Stage({ + container: containerId, + width: 578, + height: 200 + }); + var layer = new Kinetic.Layer(); + + startTimer(); + for(var n = 0; n < 1000; n++) { + var darth = new Kinetic.Image({ + x: 200, + y: 75, + image: imageObj, + width: 107, + height: 75, + draggable: true, + scale: 0.5 + }); + + layer.add(darth); + } + + stage.add(layer); + endTimer('draw 1000 scaled images'); + + }; + imageObj.src = '../assets/darth-vader.jpg'; + }, + '*draw 1000 pre-processed cropped and scaled images': function(containerId) { var imageObj = new Image(); imageObj.onload = function() { var stage = new Kinetic.Stage({