<!--
{
  "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/XCTCPUMetric/init(limitingToCurrentThread:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTCPUMetric(im)initLimitingToCurrentThread:"
  },
  "title" : "init(limitingToCurrentThread:)"
}
-->

# init(limitingToCurrentThread:)

Creates a CPU metric that optionally records data only for the current thread.

```
init(limitingToCurrentThread limitToCurrentThread: Bool)
```

## Parameters

`limitToCurrentThread`

A Boolean value that specifies whether to limit the recording of data for this metric to the current thread only.

## Discussion

If `limitToCurrentThread` is `true`, the returned metric only records data related to CPU use on the current thread. In a single-threaded context, a thread-limited metric provides lower variance and greater precision than a whole-process metric.

---

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)