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 comparer
and 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
Mapis suprisingly slow. I have experimented a bit and it seems to boil down to the generic comparer used byMap.I have experimented with adding a method to
Mapthat allows me to specify a custom comparer:and ran some performance tests. These are the numbers for the generic comparer:
These are the numbers with comparer above.
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