【问题标题】:How to measure latency in iOS如何在 iOS 中测量延迟
【发布时间】:2023-03-14 07:37:01
【问题描述】:

是否可以测量特定页面的延迟?

我可以做一些请求并计算平均值以了解延迟吗?

【问题讨论】:

标签: ios iphone ipad httprequest


【解决方案1】:

你当然可以。 你可以使用类似的东西

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse {
    //Save [NSDate date] to a local var here
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse {
   //Use [[NSDate date] timeIntervalSinceDate:*localVar*]
}

做一堆这些,把它们平均下来,你就有了延迟。 NSURLConnection 已弃用,我确信这可以用 NSURLSession 重写。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-17
    • 1970-01-01
    • 2019-03-11
    • 2021-06-07
    • 1970-01-01
    • 2015-01-23
    • 2021-01-02
    • 1970-01-01
    相关资源
    最近更新 更多