# OS_InitFunctionCost

## C Specification

  `#include <nitro/os.h>`
  `void OS_InitFunctionCost( void* buf, u32 size );`

## Arguments

buf | Function cost calculation buffer
size | Size of the function cost calculation buffer.

## Return Values

None.

## Description

This sets the buffer that will be used for function cost calculation, and begins the function cost calculation. After function cost calculation settings are made by calling this function, calculation status will be Enabled. This is the status after `OS_EnableFunctionCost()` is called.)

In order for a function to be calculated, it must be compiled with the `profile` feature ON. (When you compile with `NITRO_PROFILE=TRUE`, at compile time the `-profile` option will be attached and the profile feature will be ON.))

To enable features that are related to function cost calculation, at link time you must include `libos.FUNCTIONCOST.a` (in the thumb version `libos.FUNCTIONCOST.thumb.a`). To do this, specify `NITRO_PROFILE_TYPE=FUNCTIONCOST` as a `make` option. You may also write it in the `makefile`. However, in the final ROM version (FINALROM) library, it will not do anything.

An information header `sizeof(OSFunctionCostInfo) - sizeof(OSFunctionCost) in bytes` for function cost calculations is stored in the front of the buffer buf. The size of the information that is stored when the function is called will be `sizeof(OSFunctionCost)` bytes.

If you are using a thread system, buffers are independent for each thread. Therefore, if you want to store cost calculations, you will have to define a separate buffer in each thread.

To accumulate and display calculation results, accumulate them with `OS_CalcStatistics()` or `OS_CalcThreadStatistics()`, and then call `OS_DumpStatistics()`.

## See Also

`OS_CalcStatistics, OS_CalcThreadStatics, OS_DumpStatistics
`

## Revision History

06/02/2004 Changed description of the make options
05/18/2004 Initial version

CONFIDENTIAL