试了试cocos的schedule 他是 以秒为单位的,测试下稳定性,
输出了1000次循环的
平均值 33,
和中位数,
中位数有两个,一个是 16,出现57次,并在周围递减,
一个是 50~53,30次+,并在周围递减。
没继续测试,测试连续性,就 是,波峰波谷,分布。
需求是硬实时,唉~,再想办法吧,肯定要结合硬件了。
this.schedule(this.defFixedUpdate, 0.004);//4ms
checkTime=0;
checkTime2=1000;
ddd=0;
ttt1:number[]=[];
//
fixdfun(){
i f(this.checkTime2==1000){
for(let ii = 0;ii<100;ii++){
this.ttt1[ii]=0;
}
}
if(this.checkTime2>0){
let date1 = new Date();
let time1 = date1.getTime();
console.log("定时器 准确度 检测time1: "+time1);
let dd =(time1 - this.checkTime);
console.log("定时器 准确度 检测 delt: "+dd);
if(dd < 100){
this.ddd+=dd;
this.ttt1[dd]+=1;
}
this.checkTime = time1;
this.checkTime2--;
}else if(this.checkTime2==0){
this.checkTime2--;
console.log("定时器 准确度 检测 delt平均值: "+this.ddd/999);
}
}