From 0fbbbaa985178d35e7649acbf2200552f9ffed6f Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 6 May 2016 14:19:53 -0700 Subject: [PATCH] Add tex loadPerfTest.js --- .../tests/scriptableResource/loadPerfTest.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/developer/tests/scriptableResource/loadPerfTest.js diff --git a/scripts/developer/tests/scriptableResource/loadPerfTest.js b/scripts/developer/tests/scriptableResource/loadPerfTest.js new file mode 100644 index 0000000000..17feef264d --- /dev/null +++ b/scripts/developer/tests/scriptableResource/loadPerfTest.js @@ -0,0 +1,34 @@ +// +// loadPerfTest.js +// scripts/developer/tests/scriptableResource +// +// Created by Zach Pomerantz on 4/27/16. +// Copyright 2016 High Fidelity, Inc. +// +// Preloads 158 textures 50 times for performance profiling. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var TIMES = 50; + +Script.include([ + '../../../developer/utilities/cache/cacheStats.js', + 'lib.js', +], function() { + var fetch = function() { + prefetch(function(frames) { + while (frames.length) { frames.pop(); } + Script.requestGarbageCollection(); + + if (--TIMES > 0) { + // Pause a bit to avoid a deadlock + var DEADLOCK_AVOIDANCE_TIMEOUT = 100; + Script.setTimeout(fetch, DEADLOCK_AVOIDANCE_TIMEOUT); + } + }); + }; + + fetch(); +});