Sign In Register

How can we help you today?

Start a new topic
Answered

Scripts timings

Hello,
in Manage Tab I can make diagrams which contain script execution times. How can I get those timings out of GameSparks web site? What kind of request to server should I send to get this? I would like to get every script execution time separately of course. Thats because I just want to make my own diagrams without using GameSparks schema(which is not too good for large amount of data).


Best Answer

Marcin,


   I had the same requirement - and simply added logic to LogEventRequest and LogEventResponse to manage it.  In LogEventRequest, I do something like this to tuck the event name and start time in the calling player's private data object:


 

        var player = Spark.getPlayer();
        player.setPrivateData('loggedEventKey',Spark.getData().eventKey);
        player.setPrivateData('eventScriptStart',new Date().getTime());

 

In LogEventResponse, I do this:

  

        var dEnd = new Date();
        var dStart = Spark.getPlayer().getPrivateData('eventScriptStart');
        var loggedEventKey = Spark.getPlayer().getPrivateData('loggedEventKey');
        if(dStart && loggedEventKey) {
            var timeTaken = dEnd.getTime() - dStart;
            var eventTimingData = {
             'eventTimingScript' : loggedEventKey,
             'eventTimingDuration' : timeTaken
            };
            Spark.getLog().debug(eventTimingData);
        }

  I can then use nosql explorer to slice and dice the data any way I want.

Hope this helps!


Jeff


Hi Marcin,


I'm not sure if this is possible currently but I can look into this for you if you can confirm the requirement for me. You want to export the script duration times for specific events over a certain period. Is that correct ? You also want to export the data so you can build your own solution outside of GameSparks ? Is there any particular reason why you feel you can't achieve this on GameSparks currently ?


Thanks,

Liam

Yes I'd like to be able to write for example PHP script which with RestAPI/other query will be able to get "script duration times for specific events over a certain period". And yes thats because I'd like to make my own diagrams because those form GS aren't good enough(with them I'm not able to do a lot of things like sorting, filtering on demand, show just a table of timings by month or attach to other tool alerts if some requests executes too long).

 

Btw. I'm nearly 100% sure thats somehow possible because I can see in browser console that its getting all events data in response as JSON, But the question is what should I send to server to get proper response.

 

Hi Marcin, 


We're looking into this for you and will be back with an update soon.


Best Regards, Patrick. 

Hi Marcin,


I'm afraid it's not currently possible to export the specific data that you want here. Currently you can get the averageJsExecutionTime and averageResponseTime across all events. In a future analytics update you will be able to get a break down per event which will be generated by default. It will likely be sometime in the new year before this is available on the platform. You can keep an eye out for updates relating to this issue in our announcements forum page located here.


Thanks,

Liam

Answer

Marcin,


   I had the same requirement - and simply added logic to LogEventRequest and LogEventResponse to manage it.  In LogEventRequest, I do something like this to tuck the event name and start time in the calling player's private data object:


 

        var player = Spark.getPlayer();
        player.setPrivateData('loggedEventKey',Spark.getData().eventKey);
        player.setPrivateData('eventScriptStart',new Date().getTime());

 

In LogEventResponse, I do this:

  

        var dEnd = new Date();
        var dStart = Spark.getPlayer().getPrivateData('eventScriptStart');
        var loggedEventKey = Spark.getPlayer().getPrivateData('loggedEventKey');
        if(dStart && loggedEventKey) {
            var timeTaken = dEnd.getTime() - dStart;
            var eventTimingData = {
             'eventTimingScript' : loggedEventKey,
             'eventTimingDuration' : timeTaken
            };
            Spark.getLog().debug(eventTimingData);
        }

  I can then use nosql explorer to slice and dice the data any way I want.

Hope this helps!


Jeff


1 person likes this
Good idea, thanks! But what with performance in this case? I mean in every request it will be calculated.

 

Marcin,


     it's a minimal amount of logic to execute - and takes fractions of a millisecond of time - the only real overhead is the write-time to mongo (which is heavily optimized).  The data collected has been invaluable for analyzing performance patterns - as they pertain to time of day, specific players or other elements.  We will probably utilize a flag to disable/enable this sort of logging in production (so I only incur the expense when needed to troubleshoot) - but in preview environments, it has been super useful.  For us - this is a stopgap until GS provides us access to their own low-level per-event timings.


Best of luck!!  

Hi Marcin, 


Did you have a chance to try the solution proposed by Jeff ? It seems like a good solution for now. If you have any further questions please don't hesitate to ask. 


Thanks,

Liam



Yes, we have tried something similar

 

Login to post a comment