<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTMetric",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(pl)XCTMetric"
  },
  "title" : "XCTMetric"
}
-->

# XCTMetric

A protocol that defines the methods that objects must provide when gathering metrics during performance tests.

```
protocol XCTMetric : NSCopying, NSObjectProtocol
```

## Overview

Objects that gather metrics during performance tests must conform to `XCTMetric`. Before you create your own conforming objects, first use the metrics classes that `XCTest` supplies.

## Topics

### Recording Metrics

[`-  willBeginMeasuring`](/documentation/XCTest/XCTMetric/willBeginMeasuring())

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

[`-  didStopMeasuring`](/documentation/XCTest/XCTMetric/didStopMeasuring())

A method that XCTest calls when it has finished running the measured code.

### Reporting Gathered Metrics

[`-  reportMeasurementsFromStartTime:toEndTime:error:`](/documentation/XCTest/XCTMetric/reportMeasurements(from:to:))

Reports the measurements gathered for a metric between specific timestamps.

## Relationships

### Conforming Types

[`XCTMemoryMetric`](/documentation/XCTest/XCTMemoryMetric)

[`XCTClockMetric`](/documentation/XCTest/XCTClockMetric)

[`XCTOSSignpostMetric`](/documentation/XCTest/XCTOSSignpostMetric)

[`XCTCPUMetric`](/documentation/XCTest/XCTCPUMetric)

[`XCTHitchMetric`](/documentation/XCTest/XCTHitchMetric)

[`XCTStorageMetric`](/documentation/XCTest/XCTStorageMetric)

[`XCTApplicationLaunchMetric`](/documentation/XCTest/XCTApplicationLaunchMetric)

### Inherits From

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)