lv最高大概能达到1000多 调用getStoreLvUpNeedById大概100多次界面就非常卡 去掉Math.pow就不卡 要怎么优化性能
让策划配每级对应的表。这种事别自己算。后边需求改了就又要改,而且这样算肯定会改
1赞
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
}
let startTime = Date.now();
for(let i = 0; i < 1000; i++) {
let lv = getRandomIntInclusive(1, 1000)
let result = Math.floor(Math.pow(1.15, lv));
}
console.log("---> time cost:", Date.now() - startTime);
你可以在浏览器的调试器中执行一下这段代码,时间消耗是极小的;
内置对象Math中的函数有优化过的,不应该这么慢才对;
应该是UtilsMath中的数字转数组慢;
配置+10086,现在写公式,以后天天改公式,天天给你提需求,天天要改代码发版本


