<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTestCase/measure(metrics:options:block:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTestCase(im)measureWithMetrics:options:block:"
  },
  "title" : "measure(metrics:options:block:)"
}
-->

# measure(metrics:options:block:)

Records the selected metrics, using the specified measurement options, for a block of code.

```
func measure(metrics: [any XCTMetric], options: XCTMeasureOptions, block: () -> Void)
```

## Parameters

`metrics`

An array of metrics to measure, like CPU, memory, or elapsed time.

`options`

Options to control the gathering of performance measurements.

`block`

A block whose performance is measured.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)