-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data.Set.fromDistinctAscListN #894
Comments
Also descending versions? |
Your implementations all look weird to me. This is a deserialization problem. fromDistinctAscendingListN :: Int -> [a] -> (Set a, [a])
fromDistinctAscendingListN n xs
| s :!* remains <- fdalN n xs
= (s, remains)
data LSP a b = !a :!* b
fdalN :: Int -> [a] -> LSP (Set a) [a]
fdalN n xs | n <= 0 = Tip :!* xs
fdalN 1 (x:xs) = singleton x :!* xs
fdalN n xs
| start :*! (x : xs') <- fdalN (n `quot` 2) xs
, end :*! xs'' <- fdalN ((n-1) `quot` 2) xs'
= Bin n x start end :!* xs''
fdalN _ _ = error "List too short" |
Mine looks a lot like a direct version of your continuation-passing ones. I'd expect it to be easier on the optimizer. |
I added your version. The ST version is still faster.
I am puzzled by the timings. (so perhaps the method of measurement is not OK - or something else is not OK)
fromAscList
this is just
my ST version: best for <= 9.2
|
I agree none of this makes sense. There's no reasonable world in which adding the overhead of |
quiet: yes. consistent: yes - my run.sh does everything twice, see https://gitlab.imn.htwk-leipzig.de/waldmann/fdaln/-/blob/master/1.LOG |
I do think your test is a bit unusual. First off, why sum the sets at all? Why not just force them to WHNF? They're totally strict structures. Secondly, why not use a common benchmark system? |
OK, with tasty-bench, some sanity is restored. Still, wild fluctations w.r.t. compiler version, see https://gitlab.imn.htwk-leipzig.de/waldmann/fdaln/-/blob/master/2.LOG |
I haven't checked the linked implementations but noticed this issue so I thought I should mention, the amount of rebalancing work in (See also #949) |
just making a note that such a function (with N = length of second argument) could be useful, since an implementation can use N to determine the shape of the tree in advance, so there's no need to re-balance during construction.
see #890 (comment)
I made some experiments here https://gitlab.imn.htwk-leipzig.de/waldmann/fdaln and the timing data looks very strange...
The text was updated successfully, but these errors were encountered: