# tt_metal profiler

## Tests

### Automation tests for the profiler module

If new changes were made to the post processing scripts, please run automated test to make sure previously supported
measurements still have support.

Automated test are run by:

1. Follow the tt-metal dev get_started and general installation guide and make sure `PYTHONPATH`
   and other tt-metal environment variables are set. Activate the python environment as suggested by the guides.
2. For testing the collection side of the profiler module, run the following commands under `TT_METAL_HOME`:

```
    cd $TT_METAL_HOME
    pytest -svvv tests/tt_metal/tools/profiler/test_device_profiler.py
```

3. For testing the processing side of the profiler module, run the following commands under `TT_METAL_HOME`:

```
    cd $TT_METAL_HOME
    pytest -svvv tests/tt_metal/tools/profiler/test_device_logs.py
```

#### Adding device log file test

Fro device log file test executed by `test_device_logs.py`, when new features are added which require
modifying some or all of the golden artifacts, the following script can be used to populate the golden directory with the new format.

```
    cd $TT_METAL_HOME
    ./tests/tt_metal/tools/profiler/populate_golden.py -w
```

Note that the wipe `-w` option wipes the current golden folder and replaces its content with the new artifacts. This change will
show up in your diff for you PR when pushing the new golden artifacts. Care needs to be taken to make sure the changes are legitimate during the PR process

If new log examples need to be added, their golden artifacts can be generated by:

1. Copy the `.csv` log file to the `tt_metal/third_party/lfs/profiler/tests/golden/device/logs/` folder and name it with this format `profile_log_device_{testName}.csv`
2. Run `populate_golden.py` without the wipe option

Golden artifacts will be generated for the file and the test list file be updated for the new log
