---
title: "beginInterval(_:id:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/ossignposter/begininterval(_:id:)"
---

# beginInterval(_:id:)

Begins a signposted interval.

## Declaration

```swift
func beginInterval(_ name: StaticString, id: OSSignpostID = .exclusive) -> OSSignpostIntervalState
```

## Parameters

- `name`: The signpost’s name.
- `id`: The signpost’s identifier. The default value is doc://com.apple.os/documentation/os/OSSignpostID/exclusive.

## Mentioned in

Recording Performance Data

## Return Value

Return Value The interval state that the signposter derives from the specified id parameter.

## Discussion

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, use exclusive for the id parameter. Otherwise, use the makeSignpostID() and makeSignpostID(from:) methods to generate a signpost identifier. To end a signposted interval, pass the return value to one of the endInterval(_:_:) or endInterval(_:_:_:) methods. If you don’t have access to the returned interval state when you want to end the signposted interval, recreate it by passing the same signpost ID to the beginState(id:) method. If you need to pass the returned interval state across process boundaries, you must encode it first. For more information, see OSSignpostIntervalState. The following example demonstrates how to use a signpost ID and interval state to signpost the beginning and the end of an interval: // Create a signposter that uses the default subsystem. let signposter = OSSignposter()          // Generate a signpost ID to associate with the signposted interval. let signpostID = signposter.makeSignpostID()          // Create a name that the signposter uses, along with the  // signpost ID, to disambiguate the begin call and end call.  // The type must be StaticString. let name: StaticString = "Example Signpost"          // Begin a signposted interval and keep a reference to the // returned interval state. let state = signposter.beginInterval(name, id: signpostID)          // Perform one or more tasks that you want to measure.          // Use the interval state from the begin call to end the // corresponding signposted interval. signposter.endInterval(name, state)

## See Also

### Starting a Signposted Interval

- [beginInterval(_:id:_:)](os/ossignposter/begininterval(_:id:_:).md)
- [beginAnimationInterval(_:id:)](os/ossignposter/beginanimationinterval(_:id:).md)
- [beginAnimationInterval(_:id:_:)](os/ossignposter/beginanimationinterval(_:id:_:).md)
- [OSSignpostIntervalState](os/ossignpostintervalstate.md)
- [SignpostMetadata](os/signpostmetadata.md)
