- Thread Author
- #1
The performance of some of the game event handlers validates is having an impact on the loop delay.
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.
Code:
import com.runemate.game.api.hybrid.GameEvents;
import com.runemate.game.api.script.framework.LoopingBot;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
/**
* Created by Tom (Overflow).
*/
public class EventHandlerDebug extends LoopingBot {
long b = System.currentTimeMillis();
int count = 0;
Deque<GameEvents.GameEvent> events = new LinkedList<>();
GameEvents.GameEvent current;
@Override
public void onStart(String... strings) {
super.onStart(strings);
this.setLoopDelay(100);
Collections.addAll(events, GameEvents.RS3.values());
}
public void onLoop() {
System.out.printf("With %s enabled loop took %s\n", current != null ? current.getName() : "NA", (System.currentTimeMillis() - b));
if (current == null || count++ > 5) {
if (current != null) {
events.addLast(current);
}
events.forEach(GameEvents.GameEvent::disable);
current = events.pollFirst();
current.enable();
count = 0;
}
b = System.currentTimeMillis();
}
}
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.