GameDevTecnico / cubos

A still very barebones game engine focused on voxels and data-oriented programming
https://cubosengine.org
MIT License
83 stars 36 forks source link

Implement spans for metrics + profiling #1265

Open roby2014 opened 3 months ago

roby2014 commented 3 months ago

Problem

Current metric implementation does not support span blocks, which means, we can not have block + scope information of things. This is a problem because we can not, for example, create a flamegraph of our systems / functions / whatever profiling we want to do (as in the image) and see hierarchy, filter levels, etc..

image

Proposed Solution

Example:

static void simulateFrame(int ms)
{
    CUBOS_INFO_SPAN(); // no name provided, will use __FUNCTION__ 

    // ...

    {
        CUBOS_TRACE_SPAN("block");
        CUBOS_METRIC("something", 2.0);
    }

    // ...

    {
        CUBOS_INFO_SPAN("lowlevel");
    }

    CUBOS_DEBUG_SPAN("anotherSpan");
}

provides a structure like

simulateFrame (span)
simulateFrame:block (span)
simulateFrame:block:something (metric)
simulateFrame:lowlevel
simulateframe:anotherSpan