Showing the changes to scripts/developer/tests/scriptableResource (1 of 1 file). Show all
Unified · Split
| @@ -0,0 +1,34 @@ | ||
| 1 | +// | |
| 2 | +// loadPerfTest.js | |
| 3 | +// scripts/developer/tests/scriptableResource | |
| 4 | +// | |
| 5 | +// Created by Zach Pomerantz on 4/27/16. | |
| 6 | +// Copyright 2016 High Fidelity, Inc. | |
| 7 | +// | |
| 8 | +// Preloads 158 textures 50 times for performance profiling. | |
| 9 | +// | |
| 10 | +// Distributed under the Apache License, Version 2.0. | |
| 11 | +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | |
| 12 | +// | |
| 13 | + | |
| 14 | +var TIMES = 50; | |
| 15 | + | |
| 16 | +Script.include([ | |
| 17 | + '../../../developer/utilities/cache/cacheStats.js', | |
| 18 | + 'lib.js', | |
| 19 | +], function() { | |
| 20 | + var fetch = function() { | |
| 21 | + prefetch(function(frames) { | |
| 22 | + while (frames.length) { frames.pop(); } | |
| 23 | + Script.requestGarbageCollection(); | |
| 24 | + | |
| 25 | + if (--TIMES > 0) { | |
| 26 | + // Pause a bit to avoid a deadlock | |
| 27 | + var DEADLOCK_AVOIDANCE_TIMEOUT = 100; | |
| 28 | + Script.setTimeout(fetch, DEADLOCK_AVOIDANCE_TIMEOUT); | |
| 29 | + } | |
| 30 | + }); | |
| 31 | + }; | |
| 32 | + | |
| 33 | + fetch(); | |
| 34 | +}); | |