# Capturing profiles

?> This feature was first made available in Testground v0.5.4 + sdk-go v0.2.8.

Profiling is a powerful way to understand how the code under test behaves under the hood. Different programming languages support different types of profiles. For example, Go supports these types:

* CPU profiles.
* Heaps and allocs profiles.
* Goroutine, threads, mutex and block profiles.

Refer to the [`pprof` package godocs](https://golang.org/pkg/runtime/pprof/#Profile) for more information.

Testground has first-class support for capturing profiles continuously throughout the test execution, and it's very versatile:

* You can choose to profile all test run instances, or just a subset of them (per group).
* You can choose which profile types to record.
* You can set the sampling interval or frequency of capture for snapshot-type profiles (e.g. goroutine, heap, etc. profiles in go).

?> **Success** Because profiling is a language feature, Testground delegates the capture to the corresponding SDK by sending the profiling requirements for each instance inside the `TEST_CAPTURE_PROFILES`� env variable.

The profiles are written to the [output path for each instance](/testground/table-of-contents/analyzing-the-results.md#testground-outputs-structure), and **are available in the output bundle** generated by `testground collect` or the `testground run --collect` flag.

### Enabling profiles

You can enable profiles by setting the profiling settings under the run configuration.

**To enable profiling globally**

**composition.toml**

```toml
...

[global.run]
# this enables a continuous CPU profile, a heap profile every 5 seconds,
# and an allocs profile every 10 seconds.
profiles = { cpu = "true", heap = "5s", allocs = "10s" }

...
```

**To enable profiling in a single group**

**composition.toml**

```toml
...

[[groups]]
id = "low-latency"
[groups.run]
# same settings as above
profiles = { cpu = "true", heap = "5s", allocs = "10s" }

...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://protocol-labs.gitbook.io/testground/table-of-contents/analyzing-the-results/capturing-profiles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
