Sign In Register

How can we help you today?

Start a new topic

unstable code execution time

Hi

I have a problem with time duration when we  execute  code in real time.  

We made measurements of function execution time and we found out that, in our case, the time of code execution always vary.  the difference is quite big, for example one of our function can be executed in 1ms and in 665ms. here it is:

var sendTime = Date.now();
        logError(sendTime  + " -32");
        if(!fistPlayerId)
        {
            fistPlayerId = RTSession.getPlayers()[0].getPlayerId();
        }   
        
        for(var i = 0; i < matchData.participants.length; i++)
        {
            currentParticipantMatchData = matchData.participants[i];
            
            participantsData.push({
                playerName: currentParticipantMatchData.playerName,
                armor: currentParticipantMatchData.armor,
                maxHeals: currentParticipantMatchData.maxHeals,
                heals: currentParticipantMatchData.heals,
                currentMana: currentParticipantMatchData.currentMana + currentParticipantMatchData.intellect,
                intellect: currentParticipantMatchData.intellect,
                critChanse: currentParticipantMatchData.critChanse,
                damage: currentParticipantMatchData.baseDamage,
                lowDamage: Math.round(currentParticipantMatchData.baseDamage * .85),
                skillsData: JSON.parse(SkillsData.skillController.getSkillsData(i)),
                passiveSkill: currentParticipantMatchData.passiveSkill,
                standSkill: currentParticipantMatchData.standSkill,
                isCrit: false,
                isBlock: false,
                effects: EffectsController.getEffects(i),
                attackPoint: attackPoint[i],
                blockPoint: blockPoint[i]
            });
            
            currentParticipantData = participantsData[i];
            
            if(currentParticipantData.currentMana > currentParticipantMatchData.maxManaAmount)
            {
                currentParticipantData.currentMana = currentParticipantMatchData.maxManaAmount;
            }
            
            if(currentParticipantMatchData.playerID != fistPlayerId && _playersCount == 1)
            {
                BotSkillsController.useBotSkill(currentParticipantData, currentParticipantMatchData, i);
                currentParticipantData.skillsData = JSON.parse(SkillsData.skillController.getSkillsData(i));
            }
            
            sendTime = Date.now();
            logError(sendTime  + " -75");

  

We can not understand why the difference is so big. the function is the same all the time. 


p.s. we emulate similar code in google chrome, and the time execution there was stable and low

Login to post a comment