Windows Phone 7 设备上的 HTTP 请求性能不佳
我正在将游戏从 Silverlight 移植到 Windows Phone 7,并使用轮询 HTTP 请求作为与服务器的连接。设备上的 HTTP 请求(WebClient 或 HttpWebRequest)的性能似乎非常糟糕。模拟器运行正常。
我制作了一个超级简单的测试程序,它不断地对简单文本/纯内容进行 HTTP GET。
在 WP7 模拟器上运行该程序每秒会产生数十个请求,但在设备(HTC HD7)上仅每秒约 1 个请求,这还不够好。我尝试过 GPRS 和 WLAN 连接,结果相似。此外,WebClient 和 HttpWebRequest 方法都会给出相同的结果。
相比之下,Android 手机在相同网络中的性能要好得多。
WP7 Silverlight 网络性能是否存在一些已知的限制?它们因设备而异吗?有什么解决方法吗?
这对我的应用程序来说是一个巨大的阻碍。
编辑:当手机连接到 PC 时,请求需要大约 40 毫秒。使用 GPRS/WLAN 时,请求需要 500+ms。如前所述,Android 在没有电缆的情况下速度超快,可能大约 50 毫秒。
I'm porting a game from Silverlight to Windows Phone 7 and using polling HTTP requests as my connection to the server. It seems the performance of HTTP requests (either WebClient or HttpWebRequest) on device is extremely bad. Emulator performs ok.
I've made a super-simple test program that continuously makes HTTP GET of a simple text/plain content.
Running the program on WP7 emulator gives me dozens of requests per second but on device (HTC HD7) only about 1/sec which is not good enough. I've tried with GPRS and WLAN connection with similar results. Also both WebClient and HttpWebRequest approaches give the same result.
To compare, an Android phone in the same networks performs much, much better.
Are there some known limitations in WP7 Silverlight network performance? Do they differ from device to device? Are there any workarounds?
This is a huge showstopper for my application.
EDIT: When the phone is connected to the PC, requests take ~40ms. When using GPRS/WLAN, requests take 500+ms. As mentioned, Android is super-fast without cable, probably around 50ms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在你的网络上。根据数据量和网络速度(在您的情况下 - GPRS 和 WLAN),性能确实可能会有很大差异。当手机通过 USB 连接时,您使用的是本地以太网连接,这就是性能良好的原因。
要解决该问题,您需要:
a) 确保网络良好。不要仅在您的应用程序上尝试。查看其他站点如何加载,其他依赖于互联网的应用程序如何执行。
b) 重新建模发起 HTTP 请求的方式。尝试减少传输数据的频率和(如果可能)数据量。
The problem lies in your network. Depending on the amounts of data and network speed (in your case - GPRS and WLAN), the performance indeed can vary drastically. When the phone is connected through the USB, you are using the local Ethernet connection and that's why the performance is good.
To solve the problem, you need to:
a) make sure that the network is good. Don't try it on your app only. See how other sites load, how other Internet-dependent applications perform.
b) re-model the way you are initiating HTTP requests. Try to reduce the frequency and (if possible) - amounts of transmitted data.