an on - chip function call aware software code profiling counter system and method is disclosed . when building software code a compiler / tool - chain can modify prologues and epilogues of functions to add instrumentation code which uniquely identifies the function . each function included in the instrumented source code tree is assigned a unique identifier by the compiler / tool - chain . writing a unique id for a function to a register starts profiling for the function . the profiling is performed by a counter that counts the number of instruction cycles since the last unique id was written to the register . when a unique id for a next function to be profiled is written to the register , the old register value and the counter value are latched to one or more buffers and the counter is cleared to start the next count sequence for the next function to be profiled .