Skip to content

Instantly share code, notes, and snippets.

@achernoprudov
Created July 8, 2024 13:58
Show Gist options
  • Save achernoprudov/8c1b3bbe58825e730c500bad850afc27 to your computer and use it in GitHub Desktop.
Save achernoprudov/8c1b3bbe58825e730c500bad850afc27 to your computer and use it in GitHub Desktop.
import os.log
// Example adds logging for specific opertaion which can be traced and analyzed
// later by Xcode Profile Instruments
let log = OSLog(subsystem: "com.yourapp.subsystem", category: "performance")
let signpostID = OSSignpostID(log: log)
func performOperation() {
os_signpost(.begin, log: log, name: "Perform Operation", signpostID: signpostID)
// Simulated operation
for _ in 0..<1000000 {
_ = 1 + 1
}
os_signpost(.end, log: log, name: "Perform Operation", signpostID: signpostID)
}
// Example usage
performOperation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment