在iPhone上将流式内容写入磁盘的理想块大小 [英] Ideal Chunk Size for Writing Streamed Content to Disk on iPhone

查看:51
本文介绍了在iPhone上将流式内容写入磁盘的理想块大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个可在iPhone上缓存来自网络的流式内容的应用程序.现在,我正在将数据到达时保存到磁盘中(块大小从1KB到大约60KB),但是应用程序响应有些缓慢(比我预期的要好,但仍然很糟糕).

I am writing an app that caches streaming content from the web on the iPhone. Right now, I'm saving data to disk as it arrives (in chunk sizes ranging from 1KB to about 60KB), but application response is somewhat sluggish (better than I was expecting, but still pretty bad).

我的问题是:对于最大化设备性能应有多大的写入频率,是否有人有经验法则?

My question is: does anyone have a rule of thumb for how frequent and large writes to the device memory should be to maximize performance?

我意识到这似乎是特定于应用程序的,并且我打算针对我的情况进行性能调整,但这通常适用于iPhone上下载大量数据的任何应用程序,因为可能存在一个最佳点(给定足够的传入数据可用性))表示写入频率/大小.

I realize this seems application-specific, and I intend to do performance tuning for my scenario, but this applies generally to any app on the iPhone downloading a lot of data because there is probably a sweet spot (given sufficient incoming data availability) for write frequency/size.

这些是我已经阅读的与该问题相关的资源,但是没有人解决在转储之前要累积多少数据的特定问题:

These are the resources I've already read related to the issue, but no one addresses the specific issue of how much data to accumulate before dumping:

最佳从网络将大文件下载到iPhone以写入磁盘的方法
发现您是白痴的喜悦

推荐答案

一年后,我终于开始编写一个测试工具来测试流下载的分块性能.

One year later, I finally got around to writing a test harness to test chunking performance of streaming downloads.

这里是设置:使用iPhone 4通过带有异步 NSURLConnection 的Wi-Fi连接*下载大文件.每当下载的数据量超过阈值时,定期(以原子方式)将下载的数据刷新到磁盘.

Here's the set-up: Use an iPhone 4 to download a large file over a Wi-Fi connection* with an asynchronous NSURLConnection. Periodically flush downloaded data to disk (atomically), whenever the amount of data downloaded exceeds a threshold.

结果:这没有什么区别.使用32kB和512kB块(之间有几种大小)之间的性能差异小于使用相同块大小的两次运行之间的差异.如预期的那样,文件下载时间几乎全部由等待网络所花费的时间组成.

And the results: It doesn't make a difference. The performance difference between using 32kB and 512kB chunks (and several sizes in-between) is smaller than the variance between runs using the same chunking size. The file download time, as expected, is comprised almost entirely of time spent waiting on the network.

*平均吞吐量约为8Mbps.

*Average throughput was approximately 8Mbps.

这篇关于在iPhone上将流式内容写入磁盘的理想块大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆