[Defconapi] Extensive use of SendChatMessage 3
Robin Baumgarten
robin.baumgarten at gmail.com
Mon Oct 5 09:28:02 CDT 2009
Hi Jakub,
That's an odd behaviour, I shall investigate that. Also, I have read
something about spam-prevention in the Defcon source-code. If you want I can
look up the details and see if it causes the slow-down.
Meanwhile, did you have a look at DebugLog()? This is probably a better
method for outputting debug information.
Robin
2009/10/5 Jakub Gemrot <jakub.gemrot at gmail.com>
> Next iteration ...
>
> I've ruled out the extra thread inside JVM filling Queue of messages.
>
> Now I generate all messages inside update() method (which tooks 0ms
> together with SendChatMessage() calls as reported by
> System.currentTimeMillis() method).
> And I've observed a strange behavior of DefCon:
> 1) firstly, update() method is called regularly every 100 ms
> 2) ... then something goes wrong inside DefCon ... and update() is
> called in 150ms, next in 50ms, next in 150 ms, 50ms, 150ms, and so on
> 3) then DefCon switches to the behavior observed in previous scenario,
> the update() period gets longer and longer ...
>
> Code included...
>
> I'm wondering - how does DefCon decide - how long the game tick is?
> According to the manual the update() method is called every game tick,
> that means the tick is sometime 50ms long, sometime 150 and finally is
> degrading.
>
> Jakub
>
> P.S.: my Java code:
>
> static boolean first = true;
>
> static long start;
>
> static long lastRun = 0;
>
> public static boolean update()
> {
> long updateStart = System.currentTimeMillis();
> if (first) {
> start = System.currentTimeMillis();
> first = false;
> } else {
> SendChatMessage("Sync message, update called after " +
> (System.currentTimeMillis()-lastRun) + " ms", CHATCHANNEL_PUBLIC);
> int count = (int) ((System.currentTimeMillis()-lastRun) /
> 31);
> for (int i = 0; i < count; ++i) {
> SendChatMessage("Queue message at " +
> (System.currentTimeMillis()-start) + " ms", CHATCHANNEL_PUBLIC);
> }
> }
> lastRun = System.currentTimeMillis();
> SendChatMessage("Update() took " + (System.currentTimeMillis() -
> updateStart) + " ms", CHATCHANNEL_PUBLIC);
> 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)
> {
> }
> _______________________________________________
> Defconapi mailing list
> Defconapi at lists.introversion.co.uk
> http://lists.introversion.co.uk/listinfo/defconapi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.introversion.co.uk/pipermail/defconapi/attachments/20091005/4e908a5a/attachment.htm
More information about the Defconapi
mailing list