Bug 18400 - Searching an array with indexOf is sometimes far slower than with a for loop
Summary: Searching an array with indexOf is sometimes far slower than with a for loop
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-03-14 12:40 UTC by Randall Schmidt
Modified: 2014-03-19 18:13 UTC (History)
7 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Attached is the project we ran on Windows and the project we ran on the iPad as well as a spreadsheet comparing the runtimes of the tests. (129.01 KB, application/zip)
2014-03-14 12:40 UTC, Randall Schmidt
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED FIXED

Description Randall Schmidt 2014-03-14 12:40:42 UTC
Created attachment 6315 [details]
Attached is the project we ran on Windows and the project we ran on the iPad as well as a spreadsheet comparing the runtimes of the tests.

We noticed huge performance improvements when we changed some of our code from using indexOf to using for loops to find the index of an array entry on iPad.

In the case of searching a large enum array, a for loop is over 100x faster than indexOf.

On windows, searching a large enum array was 2.5 times faster with a for loop than with indexOf.

Attached is the project we ran on Windows and the project we ran on the iPad as well as a spreadsheet comparing the runtimes of the tests.
Comment 1 Sebastien Pouliot 2014-03-14 13:46:40 UTC
c.c. Mark
Comment 2 Marek Safar 2014-03-17 04:23:28 UTC
quite simple, we need custom equalitycomparer for enums as we have for strings
Comment 3 Marek Safar 2014-03-19 18:13:29 UTC
Fixed in master