---
title: "writeTimestamp(counterHeap:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4commandbuffer/writetimestamp(counterheap:index:)"
---

# writeTimestamp(counterHeap:index:)

Writes a GPU timestamp into the given counter heap.

## Declaration

```swift
func writeTimestamp(counterHeap: any MTL4CounterHeap, index: Int)
```

## Parameters

- `counterHeap`: doc://com.apple.metal/documentation/Metal/MTL4CounterHeap to write the timestamp into.
- `index`: The index within the doc://com.apple.metal/documentation/Metal/MTL4CounterHeap that Metal writes the timestamp to.

## Discussion

Discussion This method captures a timestamp after work prior to this command in the command buffer is complete. Work after this call may or may not have started. You are responsible for ensuring the counterHeap is of type MTL4CounterHeapType.timestamp.
