question

kwinegardner avatar image
kwinegardner asked

What does the last line of the CloudScript Executions chart represent?,Anatomy of the Cloud Script console charts

Everything but the 997.000m is pretty self explanatory, but what does the 997.000m mean?

,

Everything except the 997.000m is pretty self explanatory, but what does the 997.000m mean?

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy avatar image
Andy answered

@kwinegardner, I double checked with a few folks today and it turns out I gave you a bad answer. I confused the chart you posted with the execution time chart. On this one, the 997 is actually thousandths of an execution. I know that is confusing and I've got a bug filed on the team to make it more clear. The reason it's not just one has to do with how numbers get averaged over time for that chart.

You'll want to look at the chart to the left of that one to figure out the average run time of the function.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy avatar image
Andy answered

<deleted because I was wrong>

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy avatar image Andy ♦♦ commented ·

Thinking on it, I should probably file a request to get that changed from m, to ms. Wouldn't want someone to think we were talking about meters. :)

0 Likes 0 ·
kwinegardner avatar image kwinegardner commented ·

That's what I was afraid of... is there a more efficient way to update stats other than using the public API to GetPlayerStatistics (all)? I'm highly concerned that such a simple script took almost a second to execute. Any ideas how else I can bring this down to something reasonable? One second execution time for this is far far from a scalable option.

0 Likes 0 ·
Andy avatar image Andy ♦♦ kwinegardner commented ·

Potentially, though it depends on what you're actually doing. The main way to update stats from cloud script is via UpdatePlayerStatistics. That can update as many statistics as you'd like in a single call. If you'd like some help optimizing, can you share your cloud script code?

0 Likes 0 ·
kwinegardner avatar image
kwinegardner answered

Sure. I have pasted my code below. It is a function triggered by the occurrence of an analytic event. When I mentioned the use of GetPlayerStatistics, I was referring to the need to get them all when I just need one stat's current value in order to increment (update) it. A bit about this code, it's just a POC at this point. What we are aiming to do is increment several different values for a player upon completion of some criteria. You could think of it as maintaining all of a player's experience or grade in a particular subject.

// Function that is called from action rule for the PlayStream custom event player_completed_lesson.
// Updates the player's statistic for number of lessons completed -- LessonsCompleted
handlers.handlePlayerCompletedLesson = function (args, context) {
    // The event that triggered the action 
    var psEvent = context.playStreamEvent;
    
    var playerStats = server.GetPlayerStatistics({
        PlayFabId: currentPlayerId
    }).Statistics;
    var lessonsCompleted = 0;
    for (var i = 0; i < playerStats.length; i++) {
        if (playerStats[i].StatisticName === "LessonsCompleted") {
            lessonsCompleted = playerStats[i].Value;
          	break;
        }
    }
    lessonsCompleted += 1;
    var request = {
        PlayFabId: currentPlayerId, Statistics: [{
                StatisticName: "LessonsCompleted",
                Value: lessonsCompleted
            }]
    };
    server.UpdatePlayerStatistics(request);
    log.debug("Updated LessonsCompleted stat for player " + currentPlayerId + " to " + lessonsCompleted);
};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.