<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/OSSignposter/withIntervalSignpost(_:id:around:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os12OSSignposterV20withIntervalSignpost_2id6aroundxs12StaticStringV_AA12OSSignpostIDVxyKXEtKlF"
  },
  "title" : "withIntervalSignpost(_:id:around:)"
}
-->

# withIntervalSignpost(_:id:around:)

Measures the execution of the specified closure.

```
func withIntervalSignpost<T>(_ name: StaticString, id: OSSignpostID = .exclusive, around task: () throws -> T) rethrows -> T
```

## Parameters

`name`

The signpost’s name.

`id`

The signpost’s ID. The default value is [`exclusive`](/documentation/os/OSSignpostID/exclusive).

`task`

The closure around which to create the signposted interval.

## Discussion

The signposter uses a signpost ID to pair the beginning and the end of a signposted interval, which is necessary because multiple intervals with the same configuration and scope can be in-flight simultaneously. If only one interval with a specific configuration can execute at any particular time, pass [`exclusive`](/documentation/os/OSSignpostID/exclusive) as the `id` parameter. Otherwise, use the [`makeSignpostID()`](/documentation/os/OSSignposter/makeSignpostID()) and [`makeSignpostID(from:)`](/documentation/os/OSSignposter/makeSignpostID(from:)) methods to generate a signpost identifier, as the following example shows:

```swift
// Create a signposter using the default subsystem.
let signposter = OSSignposter()
        
// Generate a signpost ID to associate with the signpost.
let signpostID = signposter.makeSignpostID()
        
// Signpost the interval of a closure that encapsulates 
// one or more related tasks.
signposter.withIntervalSignpost("Example Signpost", id: signpostID) {
    // Perform one or more related tasks.
}
```

---

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)