Skip to content

Conversation

meooow25
Copy link
Contributor

The previous implementations went straight down the left spine, which does not match the documented complexity. We must decrement and potentially return at each step to meet O(min(n,c)).

Also add some benchmarks for size and compareSize.

For #826.


Benchmarks on GHC 9.10.1:

IntMap

Name             Time - - - - - - - -    Allocated - - - - -
                      A       B     %         A       B     %
compareSize:2     25 ns  6.0 ns  -76%     24 B    24 B    +0%
compareSize:n    7.4 μs  7.3 μs   -1%     36 B    35 B    -2%

IntSet

Name                    Time - - - - - - - -    Allocated - - - - -
                             A       B     %         A       B     %
compareSize:2            16 ns  6.4 ns  -60%     24 B    24 B    +0%
compareSize:n           255 ns  270 ns   +5%     32 B    32 B    +0%
compareSize:sparse:2     28 ns  6.4 ns  -76%     24 B    24 B    +0%
compareSize:sparse:n     17 μs   18 μs   +4%     35 B    40 B   +14%

The previous implementations went straight down the left spine,
which does not match the documented complexity. We must decrement and
potentially return at each step to meet O(min(n,c)).

Also add some benchmarks for size and compareSize.
@meooow25 meooow25 merged commit 3e619ce into haskell:master May 4, 2025
13 checks passed
@meooow25 meooow25 deleted the update-comparesize branch May 4, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant