gpt4 book ai didi

ios - mxSignpost 事件在 Xcode Organizer 中可见吗?

转载 作者:行者123 更新时间:2023-12-05 02:40:13 40 4
gpt4 key购买 nike

我可以将一些重要的代码(我想在其中观察新应用版本的性能变化)包装在

let handle = MXMetricManager.makeLogHandle(category: "Custom Category")
mxSignpost(.begin, log: handle, name: "Custom Event Name")

mxSignpost(.end, log: handle, name: "Custom Event Name")

据我所知,当我使用 MXMetricManager.shared.add(someClass) 并在 MXMetricManagerSubscriber 委托(delegate)中我每 24 小时收到一次报告,这些报告将包含为 mxSignpost(.begin)mxSignpost(.end) 之间的间隔单独的性能部分。

问题:

我可以在 Xcode Organizer 中看到上述代码中“自定义事件名称”或“自定义类别”的这些性能分离吗?

enter image description here

最佳答案

Metric 组织者在文档中没有此功能:

MetricKit goes beyond the metrics shown in the Metrics organizer to include average pixel luminance, cellular network conditions, and durations associated with custom OSSignpost events in your app. https://developer.apple.com/documentation/metrickit/improving_your_app_s_performance.

获取路标信息的唯一方法是检查 MXMetricPayload:

import UIKit
import MetricKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MXMetricManager.shared.add(self)
return true
}

func applicationWillTerminate(_ application: UIApplication) {
MXMetricManager.shared.remove(self)
}
}

extension AppDelegate: MXMetricManagerSubscriber {
func didReceive(_ payloads: [MXMetricPayload]) {
for payload in payloads {
if let signpostMetrics = payload.signpostMetrics {
for metric in signpostMetrics {
print(metric.description)
}
}
}
}
}

关于ios - mxSignpost 事件在 Xcode Organizer 中可见吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68660602/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com