-
Notifications
You must be signed in to change notification settings - Fork 847
Closed
Labels
Area-LibraryIssues for FSharp.Core not covered elsewhereIssues for FSharp.Core not covered elsewhereFeature Request
Milestone
Description
Map is suprisingly slow. I have experimented a bit and it seems to boil down to the generic comparer used by Map.
I have experimented with adding a method to Map that allows me to specify a custom comparer:
let comparer =
{ new IComparer<Key> with
member x.Compare (l, r) = l.Value.CompareTo r.Value
}
Map.emptyWithComparer comparerand ran some performance tests. These are the numbers for the generic comparer:
Running test case: Map - Lookup......It took 8686 ms, CC=0, 0, 0
Running test case: Map - Insert......It took 9838 ms, CC=458, 0, 0
Running test case: Map - Remove......It took 7388 ms, CC=387, 0, 0
These are the numbers with comparer above.
Running test case: Map - Lookup......It took 347 ms, CC=0, 0, 0
Running test case: Map - Insert......It took 1897 ms, CC=458, 0, 0
Running test case: Map - Remove......It took 1342 ms, CC=387, 0, 0
So it do seem the comparer affect performance and it could be beneficial for performance sensitive applications to be able to provide a customer comparer.
Now; is this something that would be worth creating a PR for or are there reasons why this is not desired?
Regards,
Mårten
gusty, rojepp, cloudRoutine, isaksky, abelbraaksma and 2 moreadelarsq
Metadata
Metadata
Assignees
Labels
Area-LibraryIssues for FSharp.Core not covered elsewhereIssues for FSharp.Core not covered elsewhereFeature Request