<commit_before>require "fritomod/ListenerList";

Rainback = Rainback or {};

local boundsCache;
function Rainback.ClearCache()
    boundsCache = setmetatable({}, {
        __mode = "k"
    });
end;
Rainback.ClearCache();

function Rainback.GetCached(bound)
    return boundsCache[bound];
end;

function Rainback.SetCache(bound, value)
    boundsCache[bound] = value;
end;

local renderers = ListenerList:New();

function Rainback.AddRenderer(renderer, ...)
    return renderers:Add(renderer, ...);
end;

function Rainback.Render(painter)
    trace("FRAME start");
    local start = Rainback.GetTime();

    Rainback.ClearCache();

    renderers:Fire(painter);

    painter:reset();
    painter:setPenColor(0, 0, 0, 255);

    local elapsed = Rainback.GetTime() - start;
    if elapsed > 0 then
        local fps = 1000 / elapsed;

        local bar = "[";
        local SCALE = 2;
        local GOAL = 1000 / 60;
        for i=1, math.max(GOAL / SCALE, math.floor(elapsed / SCALE)) do
            if i * SCALE > elapsed then
                bar = bar .. " ";
            elseif i * SCALE > GOAL then
                bar = bar .. "!";
            else
                bar = bar .. ".";
            end;
        end;
        if elapsed < GOAL then
            bar = bar .. "]";
        end;

        local numRenderers = renderers:GetListenerCount();

        printf("%3dms elapsed, %3dfps %3d renderers %s",
            elapsed,
            fps,
            numRenderers,
            bar
        );
    else
        printf("  0ms elapsed, ---fps %4d renderers",
            numRenderers
        );
    end;
    trace("FRAME complete");
end;
<commit_msg>Make FPS printing trace instead of print<commit_after>require "fritomod/ListenerList";

Rainback = Rainback or {};

local boundsCache;
function Rainback.ClearCache()
    boundsCache = setmetatable({}, {
        __mode = "k"
    });
end;
Rainback.ClearCache();

function Rainback.GetCached(bound)
    return boundsCache[bound];
end;

function Rainback.SetCache(bound, value)
    boundsCache[bound] = value;
end;

local renderers = ListenerList:New();

function Rainback.AddRenderer(renderer, ...)
    return renderers:Add(renderer, ...);
end;

function Rainback.Render(painter)
    trace("FRAME start");
    local start = Rainback.GetTime();

    Rainback.ClearCache();

    renderers:Fire(painter);

    painter:reset();
    painter:setPenColor(0, 0, 0, 255);

    local elapsed = Rainback.GetTime() - start;
    if elapsed > 0 then
        local fps = 1000 / elapsed;

        local bar = "[";
        local SCALE = 2;
        local GOAL = 1000 / 60;
        for i=1, math.max(GOAL / SCALE, math.floor(elapsed / SCALE)) do
            if i * SCALE > elapsed then
                bar = bar .. " ";
            elseif i * SCALE > GOAL then
                bar = bar .. "!";
            else
                bar = bar .. ".";
            end;
        end;
        if elapsed < GOAL then
            bar = bar .. "]";
        end;

        local numRenderers = renderers:GetListenerCount();

        trace(("%3dms elapsed, %3dfps %3d renderers %s"):format(
            elapsed,
            fps,
            numRenderers,
            bar
        ));
    else
        trace(("  0ms elapsed, ---fps %4d renderers"):format(
            numRenderers
        ));
    end;
    trace("FRAME complete");
end;

{'fraction_non_alphanumeric': 0.12421618393550314, 'fraction_numerical': 0.01433263660794267, 'mean_word_length': 1.9463500439753738, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3703702', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1023, 'n_words': 260}