Share via


/fastcap - Enable fastcap profiling

This option causes the compiler to insert calls to profiling hooks around each function call. This form of profiling provides more detail than the /callcap -Enable callcap profiling form of profiling but introduces more overhead.

Note   The fastcap switch is not supported on x86 microprocessors.

Note that you must compile profiling hook functions without the fastcap switch. If you compile the profiling hooks with the fastcap switch, the functions will perform infinite recursive calls to themselves.

The following example, fastcap.c, shows a profiling hook function, _CAP_Start_Profiling, for compilation without fastcap. The compiler inserts calls to this profiling hook when you compile the subsequent routine, main.c, with the fastcap switch.

#include <stdio.h>
void _stdcall _CAP_Start_Profiling(void *CurrentProcAddr, void *TargetProcAddr)
{
    printf("Calling %s (at address %p) at tick %d\n", 
        TargetProcAddr == printf? "printf":"function", TargetProcAddr, 
        GetTickCount());
    return;
}

void _stdcall _CAP_End_Profiling(void *CurrentProcAddr)
{
    printf("Left function at tick %d\n", GetTickCount());
    return;
}

The next example shows how the compiler inserts calls to the profiling hooks from main.c. Compile main with the fastcap switch, and link with fastcap.obj that you compiled without the fastcap switch in the preceding example.

#include <stdio.h>
int main()
{
    char str[] = "\nA very, very, very, very, very long Hello World string";

    // The profiling hook, _CAP_Start_Profiling function,
    // is called here, instead of inside the printf function.
    // This makes it possible to profile a precompiled library function.

    printf("%s %s %s %s %s \n\n", str, str, str, str, str);

    // The profiling hook, _CAP_End_Profiling function, is called here,
    // after the function printf returns.

    return 0;
}

The fastcap switch inserts calls to profiling hooks before calling the function and after the call return. In contrast, callcap inserts calls to profiling hooks after entering the function and again before leaving it.

See Also

About Microprocessor Compilers | ARM Guide | Hitachi Guide | MIPS Guide | /callcap -Enable callcap profiling

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.