代码之家  ›  专栏  ›  技术社区  ›  zumzum

操作系统标志在模拟器上工作,但在设备上运行时不工作

  •  4
  • zumzum  · 技术社区  · 7 年前

    我在一个函数中有下面几行代码,我想用仪器来跟踪时间。当我从instruments在模拟器上运行这个应用程序时,会显示操作系统标志的测量时间,我可以准确地测量我需要的时间。

    然后我切换到设备,同样的代码。然而,当它在设备上运行时,仪器并没有显示测量的时间。它只显示: enter image description here

    操作系统路标时间根本没有出现。

    所以,在模拟器上一切都很好,但当我切换到我的iPhone设备时就不行了。

    知道吗?

    let spid = OSSignpostID(log: SignpostLog.myLog, object: myObj as AnyObject)
    
    defer { os_signpost(.end, log: SignpostLog.myLog, name: "operation1", signpostID: spid) }
    
    os_signpost(.begin, log: SignpostLog.myLog, name: "operation1", signpostID: spid)
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   zumzum    7 年前

    原来操作系统标志不会出现,因为录制设置为立即。设置为 推迟 这样我就可以运行应用程序,然后停止录制,然后仪器显示我在代码中的自定义操作系统标志。

    enter image description here

        2
  •  0
  •   Tim    7 年前

    确保您没有禁用 OS_ACTIVITY_MODE 通过一个环境变量(见下面的截图)

    Do not do this, or signposts will not work

    我把它移走了一切都正常了