Skip to content

PROFILE_FUNCTION() actually profiles the scope in which it is declared not the function #2

@mhdshameel

Description

@mhdshameel

It is a bit misleading.
Consider the following scenario:

void sample_function()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(500));
    {
        PROFILE_FUNCTION();
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
    }
}

Here only the 2nd sleep of 100 ms will be recorded as per the implementation of constructing and destructing of the InstrumentationTimer.
The naming might be a bit misleading. Maybe function profiling can be achieved in a different way and leave this to scope profiling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions