问题描述
我一直在读到 Wp8.1 (XAML) 应用程序是为 Windows Phone 8.1 创建应用程序的新方法,并且该代码对于 Windows 8.1 桌面应用程序具有高度可重用性.
I have been reading that Wp8.1 (XAML) apps are the new way of creating apps for Windows Phone 8.1, and the code is highly reusable for Windows 8.1 Desktop apps.
但我有点担心,因为从联系人(WP8.1 XAML 中的联系人管理器)执行单个搜索比 Silverlight 对应的要慢得多.
But im a bit worried since performing a single search from the Contacts (ContactManager in WP8.1 XAML) is way slower than the Silverlight counterpart.
在我的 Lumia 1520 中,仅从我的议程中返回所有联系人(240 个带有电子邮件、缩略图等的联系人)需要 3 秒钟;使用 Silverlight 代码执行相同的操作需要 0.7 秒.
Just returning all contacts from my Agenda (240 contacts with emails, thumbnails, etc...) takes 3 seconds in my Lumia 1520; the same operation with Silverlight code takes 0,7 seconds.
我有点害怕使用 WP8.1 制作手机应用程序,因为性能对我来说非常重要.在 Lumia 535 上的相同测试分别需要 7 秒和 1.5 秒,而我的 Lumia 1520 的触点.
I am a bit afraid to use WP8.1 to makes apps for phone cause the performance is pretty important to me. The same test on a Lumia 535 takes 7 seconds and 1,5 seconds respectively with the contacts from my Lumia 1520.
对于使用什么样的项目有什么建议吗?我觉得 Silverlight 应用程序(显然)专注于 Windows Phone 并使用手机的所有功能.
Is there any recomendation on what kind of project to use? I feel Silverlight apps are (obviously) focused in Windows Phone and use all the phone's capabilities.
我错了吗?我是否正在通过选择 Windows Phone Silverlight 进入弃用之路?
I am wrong? Am I heading into a deprecation road by picking windows phone silverlight?
注意:用于执行搜索的代码来自 MSDN 示例...
Note: The code used to perform the search is the one from the MSDN Examples...
WP8.1 XAML(Nokia Lumia 1520,3 秒获得 240 个带有缩略图、邮件帐户等的联系人...)
ContactStore agenda = await ContactManager.RequestStoreAsync();
Stopwatch sw = new Stopwatch();
IReadOnlyList<Windows.ApplicationModel.Contacts.Contact> contacts = null;
sw.Start();
contacts = await agenda.FindContactsAsync();
sw.Stop();
txtblock1.Text = sw.ElapsedMilliseconds;
WP Silverlight 8.1(Nokia Lumia 1520,0.7 秒获得 240 个带有缩略图、邮件帐户等的联系人...)
Contacts agenda = new Contacts();
//Stopwatch is declared at class level so its accessible in ListContacts_SearchCompleted Callback
sw.Start();
agenda.SearchCompleted+= ListContacts_SearchCompleted;
agenda.SearchAsync(String.Empty, FilterKind.None, null);
//sw.Stop() and print ElapsedMilliseconds in ListContacts_SearchCompleted callback
Post created in forums regarding this https://social.msdn.microsoft.com/forums/windowsdesktop/en-us/1e0accaf-b2f8-4d68-b5ec-dc6af6351633/findcontactsasync-takes-long-time?referrer=http://social.msdn.microsoft.com/forums/windowsdesktop/en-us/1e0accaf-b2f8-4d68-b5ec-dc6af6351633/findcontactsasync-takes-long-time?referrer=http://social.msdn.microsoft.com/forums/windowsdesktop/en-us/1e0accaf-b2f8-4d68-b5ec-dc6af6351633/findcontactsasync-takes-long-time?forum=wpdevelop
推荐答案
你们在比较同一个东西吗?
Are you comparing the same thing?
在 Silverlight 版本中,您只能在完成处理程序中调用 sw.Stop.
In the Silverlight version, you can only call sw.Stop in completion handler.
如果你真的想做一个好的比较,你应该得到一个 ETW 跟踪;然后你就可以真正了解发生了什么.
If you really want to do a good comparison, you should get an ETW trace; then you can really understand what's going up.
对于基于 Metro XAML 的解决方案,可能会有额外的互操作成本.但这似乎是未来的道路.
For Metro XAML based solution, there may be extra interop cost. But that seems to be the future path.
对于 Silverlight,现有 API 可能会更加完善以提高性能.
For Silverlight, existing API may be more polished for perf.
也许您应该同时研究这两种解决方案,使可共享的代码尽可能大,然后再决定采用哪种方式.
May be you should work on both solutions, make shareable code as big as possible, and later decide which way to take.
这篇关于WP SilverLight 8.1 与 WP 8.1 (XAML) 的优缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!