<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLDevice/sampleTimestamps()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So9MTLDeviceP5MetalE16sampleTimestampss6UInt64V3cpu_AF3gputyF"
  },
  "title" : "sampleTimestamps()"
}
-->

# sampleTimestamps()

Captures and returns a CPU timestamp and a GPU timestamp from the same moment in time.

```
func sampleTimestamps() -> (cpu: MTLTimestamp, gpu: MTLTimestamp)
```

## Return Value

A tuple that contains the CPU and GPU timestamps.

- `cpu`: A timestamp from the CPU.
- `gpu`: A timestamp from the GPU the device instance represents.

## Discussion

For an example of how and when to use corresponding timestamps from the CPU and GPU, see [Converting GPU timestamps into CPU time](/documentation/Metal/converting-gpu-timestamps-into-cpu-time).

---

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)