# @profiler

The keyword is used to start or stop the profiling or check if the profiling started or not.

By default the profiler is automatically started for each component when the program starts. This can be changed in the configuration file.

Detailed description can be found in the Programmers' Reference Guide.

> 1. Stopping the profiler

> 2. Starting the profiler

> 3. Checking the profiler running state

Related keywords:

- start
- stop
- running

### 1. Stopping the profiler

### @profiler.stop

The profiler can be stopped using the @profiler.stop command. This only affects profiling and code coverage in the current component

When stopped the profiler does not measure new data.

This command has no effect if the profiler is already stopped.

### 2. Starting the profiler

### @profiler.start

A stopped profiler can be restarted with the @profiler.start command. This only affects profiling and code coverage in the current component.

Similarly, this has no effect if the profiler is already running.

The execution count of a function is measured at the start of the function, thus if the profiler is stopped when the function is called, its call will not be measured, even if the profiler is restarted during the functionâs execution.

### 3. Checking the profiler running state

### @profiler.running

The boolean value @profiler.running stores the state of the profiler in the current component (true if itâs running or false if itâs stopped).

### Example:

function f1(inout integer x) runs on C
{
var boolean stop_prof := not @profiler.running;
@profiler.start;
x := x + c1;
if (stop_prof) {
@profiler.stop;
}
}

This function is always profiled and returns the profiler to its original state.