Exemple #1
0
void FW::profileEnd(bool printResults)
{
    if (!Thread::isMain())
        fail("profileEnd() can only be used in the main thread!");
    if (!s_profileStarted)
        return;

    // Pop remaining timers.

    while (s_profileStack.getSize())
        profilePop();

    // Recurse and print.

    if (printResults && s_profileTimers.getSize() > 1)
    {
        printf("\n");
        Array<Vec2i> stack(Vec2i(0, 0));
        while (stack.getSize())
        {
            Vec2i entry = stack.removeLast();
            const ProfileTimer& timer = s_profileTimers[entry.x];
            for (int i = timer.children.getSize() - 1; i >= 0; i--)
                stack.add(Vec2i(timer.children[i], entry.y + 2));

            printf("%*s%-*s%-8.3f",
                entry.y, "",
                32 - entry.y, timer.id.getPtr(),
                timer.timer.getTotal());

            printf("%.0f%%\n", timer.timer.getTotal() / s_profileTimers[0].timer.getTotal() * 100.0f);
        }
        printf("\n");
    }

    // Clean up.

    s_profileStarted = false;
    s_profilePointerToToken.reset();
    s_profileStringToToken.reset();
    s_profileTimerHash.reset();
    s_profileTimers.reset();
    s_profileStack.reset();
}
Exemple #2
0
void FW::popMemOwner(void)
{
#if FW_MEM_DEBUG
    U32 threadID = Thread::getID();
    Array<const char*>* stack = s_memOwnerStacks.search(threadID);
    if (stack)
    {
        stack->removeLast();
        if (!stack->getSize())
        {
            s_memOwnerStacks.remove(threadID);
            if (!s_memOwnerStacks.getSize())
                s_memOwnerStacks.reset();
        }
    }
#endif
}