ios - Alamofire 5 - file download execution time (Swift 5)
问题描述
I've just updated my project from Alamofire 4 to Alamofire 5 and updating code where required, but there's one that I can't find any help in the reference docs or previous posts regarding the time taken to download.
In previous version I used "response.timeline.totalDuration it provides time interval in seconds from the time the request started to the time response serialization completed." from (Checking response Time of API in iOS using Swift 3?).
Any help to get method for Alamofire 5 would be greatly appreciated.
解决方案
You should now use response.metrics.taskInterval
. This returns a DateInterval describing how long it took from the initiation of the network request to the completion. More info: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#download-progress
If you want to get this duration in seconds try response.metrics.taskInterval.duration
推荐阅读
- symfony - 使用 Symfony 通过 API 验证实体
- excel - 用字典键计算
- javascript - 适应上一个问题,ReferenceError: object is not defined
- odata - 调用我的 odata 服务时是否可以使用与我的 SAP UI5 应用程序的登录语言不同的语言?
- sql - IN 子句导致查询运行缓慢
- c# - 下拉菜单未在 MVC 中设置值
- javascript - 我在 Fetch API 中设置了授权承载,但我的请求标头中没有授权
- python - 如何在Python列表中替换列表中的项目
- performance - 在 Flutter 中创建和保存动画对象的最佳位置?
- reactjs - 如何在反应中处理带有消息的错误代码