You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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-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" }
...
```