@ypengju1 写道:
let filename = "bg/background_4" let startTime = new Date().getTime() for (var j = 0; j < 1000; j++) { cc.loader.loadRes(filename, cc.SpriteFrame, function (err, frame) { if (err) { cc.log(err.message || err); return; } }); } let endTime = new Date().getTime() cc.log("===eventTime", endTime - startTime)
每次调用上边代码,耗时会越来越长,跟踪了下代码,发现是在LoadingItems中的下边这个方法
LoadingItems.finishDep = function (depId) { for (var id in _queueDeps) { var queue = _queueDeps[id]; // Found root queue if (queue.deps.indexOf(depId) !== -1 && queue.completed.indexOf(depId) === -1) { queue.completed.push(depId); } } };
_queueDeps
会越来越大,for循环耗时越来越久
帖子: 3
参与者: 1