[Defconapi] Extensive use of SendChatMessage 4 - Conclusion
Jakub Gemrot
jakub.gemrot at gmail.com
Mon Oct 5 09:26:01 CDT 2009
CONCLUSION!
I've finally confirmed that SendChatMessage() is a method to blame!
Check the code.
Rule of thumb:
If you send one message per 10 update()s, the DefCon will run just OK.
If you send 1 or more messages per update(), you're asking for trouble
- the performance of DefCon will start to degrade.
Jakub
P.S.: my Java code:
static boolean first = true;
static int update = 0;
static long start;
static long updateStart = 0;
public static boolean update()
{
if (first) {
start = System.currentTimeMillis();
first = false;
updateStart = System.currentTimeMillis();
return true;
}
++update;
if (update == 10) {
// send message every 10th update() call
long time = System.currentTimeMillis()-updateStart;
SendChatMessage(update + "th update after " + time + " ms, one
update avg " + (time/update) + " ms" , CHATCHANNEL_PUBLIC);
updateStart = System.currentTimeMillis();
update = 0;
}
return true;
}
public static boolean initialise(String[][] _commandLineOptions)
{
SendChatMessage("Initialised...", CHATCHANNEL_PUBLIC);
return true;
}
public static void addEvent(int _eventType, int _causeObjectId,
int _targetObjectId,
int _unitType, float _longitude, float _latitude)
{
}
More information about the Defconapi
mailing list