1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bug Game Event Handlers - Loop Delay

Discussion in 'Developer Support' started by Overflow, Jan 12, 2017.

  1. Overflow

    Joined:
    Mar 26, 2014
    Messages:
    33
    Likes Received:
    4
    The performance of some of the game event handlers validates is having an impact on the loop delay.

    Code (Text):
    1. import com.runemate.game.api.hybrid.GameEvents;
    2. import com.runemate.game.api.script.framework.LoopingBot;
    3.  
    4. import java.util.Collections;
    5. import java.util.Deque;
    6. import java.util.LinkedList;
    7.  
    8.  
    9. /**
    10. * Created by Tom (Overflow).
    11. */
    12. public class EventHandlerDebug extends LoopingBot {
    13.  
    14.     long b = System.currentTimeMillis();
    15.     int count = 0;
    16.     Deque<GameEvents.GameEvent> events = new LinkedList<>();
    17.     GameEvents.GameEvent current;
    18.  
    19.     @Override
    20.     public void onStart(String... strings) {
    21.         super.onStart(strings);
    22.         this.setLoopDelay(100);
    23.         Collections.addAll(events, GameEvents.RS3.values());
    24.     }
    25.  
    26.     public void onLoop() {
    27.         System.out.printf("With %s enabled loop took %s\n", current != null ? current.getName() : "NA", (System.currentTimeMillis() - b));
    28.         if (current == null || count++ > 5) {
    29.             if (current != null) {
    30.                 events.addLast(current);
    31.             }
    32.             events.forEach(GameEvents.GameEvent::disable);
    33.             current = events.pollFirst();
    34.             current.enable();
    35.             count = 0;
    36.         }
    37.         b = System.currentTimeMillis();
    38.     }
    39. }
    40.  

    On my system running the above the interface closer takes 800 - 900ms and the grim reaper around 100ms to validate. The reaper isn't a massive problem, 100ms could be accounted for within the specified delay of each loop but the interface closer is an issue.
     
  2. Cloud

    Cloud Engineer

    Joined:
    Jul 28, 2013
    Messages:
    2,777
    Likes Received:
    1,124
    This issue is acknowledged by myself. I ran some genuine profiling and as expected they were understandably expensive. I'll come up with a solution in th near future.
     

Share This Page

Loading...