Not seeing signposts when profiling a unit test (Xcode 16.1)

While I was recently profiling some code from a Swift library, I noticed that XCTest added in signposts for the measurement tests, which I found really helpful to "home in" on the code I wanted to profile digging around in the stack trace.

I tried to add my own signposts to provide just a bit of my own markers in there, but while it compiles and profiles equivalently, the signposts just aren't showing up. This is with Xcode 16.1, macOS Sequoia (15.1) and a swift library, using XCTest and profiling within one of the unit tests.

Is there something in this sequence that doesn't allow the library to set up signposts and have instruments collect them?

The flow I'm using:

import os
let subsystem = "MyLibrary"

class MyClass {
  let logger: Logger = .init(subsystem: subsystem, category: "fastloop")
  let signposter: OSSignposter
  init() {
    signposter = OSSignposter(logger: logger)
  }

  func goFast() {
    let signpostId = signposter.makeSignpostID()
    let state = signposter.beginInterval("tick", id: signpostId)
    // ... do a bunch of work here - all synchronous
    signposter.endInterval("tick", state)
  }
}

Is there something I'm doing incorrectly in using this API, or not enabling to allow those signposts to be collected by the profiler?

I do see the signposts that XCTests injects into the system, just not any of the ones I'm creating.

Answered by heckj in 814801022

My error here was in how I created the Signposter. To get a segment to show up on the PointsOfInterest in the profiler, you need to create it with the preset category of .pointsOfInterest. For example, instead of:

signposter = OSSignposter(logger: logger)

I should have set it:

signposter = OSSignposter(subsystem: "MySubsystem", category: .pointsOfInterest)

(thank you James Dempsey) - who also pointed out that I could add the different os_signpost instrument to see the ones that I'd created with the original method. They just didn't show up in the PointsOfInterest segment of the time profiler.

Accepted Answer

My error here was in how I created the Signposter. To get a segment to show up on the PointsOfInterest in the profiler, you need to create it with the preset category of .pointsOfInterest. For example, instead of:

signposter = OSSignposter(logger: logger)

I should have set it:

signposter = OSSignposter(subsystem: "MySubsystem", category: .pointsOfInterest)

(thank you James Dempsey) - who also pointed out that I could add the different os_signpost instrument to see the ones that I'd created with the original method. They just didn't show up in the PointsOfInterest segment of the time profiler.

Not seeing signposts when profiling a unit test (Xcode 16.1)
 
 
Q