---
title: willBeginMeasuring()
framework: xctest
role: symbol
role_heading: Instance Method
path: xctest/xctmetric/willbeginmeasuring()
---

# willBeginMeasuring()

A method that XCTest calls when it’s ready to begin running the measured code.

## Declaration

```swift
optional func willBeginMeasuring()
```

## Discussion

Discussion XCTest calls this method before it runs a test’s measure() or measure(metrics:) block. It calls the method once for each iteration of a performance test. Use this method to start gathering measurements.

## See Also

### Recording Metrics

- [didStopMeasuring()](xctest/xctmetric/didstopmeasuring().md)
