I watched Getting started with Instruments and there they show the usage of Signposts. The example is written in Swift but I'd like to use them with my Objective-C project.
In these example the signpost start and end are set inside the function which means they will be triggered accordingly. My project is a plugin and its structured differently where I only have a "main" function that gets called once and then I use a series of methods from a custom class to load and parse different kind of data. As it is all sequential ... can I have only one os_log_t
and os_signpost_id_t
and reutilize it over and over again with os_signpost_interval_begin
+ os_signpost_interval_end
? Or is this not safe as the method could return after the end
was triggered? Or could they have conflicts if they get called meny times so quickly?
Thanks.
// Initialize
os_log_t log = os_log_create("com.example.plugin", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
os_signpost_id_t spid = os_signpost_id_generate(log);
// Measurement 1
os_signpost_interval_begin(log, spid, "testMethodA started");
[MyClass testMethodA:arg1 withOptions:arg2];
os_signpost_interval_end(log, spid, "testMethodA finished");
// Measurement 2
os_signpost_interval_begin(log, spid, "testMethodB started");
[MyClass testMethodB:arg1 withOptions:arg2];
os_signpost_interval_end(log, spid, "testMethodB finished");
[...]