class PerformanceTest extends Mutator;

var int counter;
var int sampleSize;
var array<int> groups;
var array<float> outliers;

public function PostBeginPlay()
{
    groups[0] = 0;
    groups.length = 20;
}

public function Tick(float delta)
{
    local int i;
    local bool added;
    local float increment, nextBreakPoint;
    local string output;
    delta *= 1000;
    increment = (0.6 * (1000/30)) / groups.length;
    nextBreakPoint = (1000/30) + increment;
    for (i = 0; i < groups.length; i += 1)
    {
        if (delta <= nextBreakPoint)
        {
            groups[i] = groups[i] + 1;
            added = true;
            sampleSize += 1;
            break;
        }
        nextBreakPoint += increment;
    }
    if (!added) {
        outliers[outliers.length] = delta;
    }
    if (counter % 180 == 0)
    {
        output = "Slowdowns: ";
        for (i = 0; i < groups.length; i += 1) {
            output $= (100 * float(groups[i]) / sampleSize) $ "/";
        }
        Log(output);
        output = "Slowdowns (count): ";
        for (i = 0; i < groups.length; i += 1) {
            output $= groups[i] $ "/";
        }
        Log(output);
        output = "Outliers: ";
        for (i = 0; i < outliers.length; i += 1) {
            output $= outliers[i] $ "/";
        }
        Log(output);
    }
    counter += 1;
}

defaultproperties
{
}