Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 24387 [details]
Performance degradation when Linq Expressions are used for Xamarin Forms Android platform
I had experienced a strange performance degradation when expressions are used for iteration of elements in my application. Here, I am explaining the scenario below.
I have 25000 items as type of IEnumerable which is converted into IQueryable elements, in order to get the OrderBy expressions for further process. And adding those elements in a foreach loop into an another collection where I had noticed the delay to complete the iteration.
For UWP platform, the iteration gets completed with noticeable time and for iOS platform, it took additional time when compared to UWP platform. But for Android platform, there was an adorable time delay. Please find the time variation for different platforms below.
Platform Time taken in millisecond
I used a Stopwatch to measure how many milliseconds it took to complete the iteration of elements in a button click event. I have attached the sample in the attachment for your reference.
Can you please let me know how do I overcome from this delay? Also, whether the time delay for iOS platform is noticeable or it is a bug?
Please let us know if you require further assistance.
Dinesh Babu Yadav
Hi Team, Any update on this?
Created attachment 24739 [details]
Because this happens even when not using Xamarin.Forms I'm inclined to say that this is a Xamarin.Android or Mono issue (similar to or possibly related to bug 56240) so I am reassigning the report.
I minimized the original repro project further and also added a basic console app. Iterating over a Queryable that uses a LINQ expression on Android, iOS, and Mono all took noticeably longer than on Windows.
# Test Results
I ran the operation 5 times without the debugger attached and average the times.
Avg: 107.6 ms
## Xamarin.Android 22.214.171.124
Avg: 1769.2 ms
## Xamarin.iOS 10.14.0.26
Avg: 754 ms
## Mono 126.96.36.199 (macOS)
Avg: 803.2 ms
## Mono 4.8.1 (macOS)
Avg: 1044 ms
Because the performance on Mono 5.4 is still better compared to Mono 4.8 I don't believe this is a regression.
Created attachment 24787 [details]
profiler run output
I attached the profiler output of the Console project run with a list of 250k items (instead of 25k in the provided repro).
What can be observed from the profiler output is around 80% of the time is spent comparing strings, which is the core of the application, as it's trying to sort 250k strings (25k in the provided repro).
So the application might be slower on Mono compared to .NET due to faster string comparison on .NET.
This is down to culture-specific comparison which we know it's slower than .net
Changing the code to be
> query = source.OrderBy(TestItem => TestItem.Name, StringComparer.Ordinal);
shows we are slower but not that much