Live code snippets that demonstrates the performance issues:
app.klipse.tech?cljs_in=...
<http://app.klipse.tech/?cljs_in=(ns%20my.diff%20%0A%20%20(%3Arequire%20%5Bclojure.data%20%3Aas%20d%20%3Arefer%20%5Bdiff%5D%5D))%0A%0A(let%20%5BdoDiff%20(fn%5Ba%20b%5D%20(time%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(let%20%5Bdelta%20(diff%20a%20b)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B(first%20delta)%20(second%20delta)%5D)))%0A%20%20%20%20%20%20x%20%20%20%20%20%20(into%20%7B%7D%20(map%20vec%20(partition%202%20(range%20100000))))%0A%20%20%20%20%20%20x1%20%20%20%20%20(into%20%7B%7D%20(map%20vec%20(partition%202%20(range%20100000))))%0A%20%20%20%20%20%20y%20%20%20%20%20%20(assoc%20x%20-1%20-1)%5D%0A%20%20%5B(doDiff%20x%20x)%0A%20%20%20(doDiff%20x%20x1)%0A%20%20%20(doDiff%20x%20y)%5D)&eval_only=1>
On Thursday, 8 September 2016 05:16:31 UTC+3, Marshall handheld Flax wrote:
>
> Suppose I create a decently-sized persistent map, and then make a small
> change. Clojure is extremely efficient at creating a second persistent map
> that shares most of its internal data with the first map, but
> clojure.data/diff appears to be unable to take advantage of that shared
> internal data -- instead it seems to just exhaustively compare the two
> trees.
>
> Comparing a map with itself: "Elapsed time: 0.155404 msecs"
> Comparing two identical -- but separately-created maps -- "Elapsed time:
> 43.687906 msecs"
> Comparing a map and one with a small change thereof: "Elapsed time:
> 378.754266 msecs"
>
> Is there a way of comparing two maps that takes advantage of the internals
> of the commonality between maps "x" and "y" below?
>
> Many thanks!!!
>
> Marshall
>
> (let [doDiff (fn[a b] (time
> (let [delta (clojure.data/diff a b)]
> [(first delta) (second delta)])))
> x (into {} (map vec (partition 2 (range 100000))))
> x1 (into {} (map vec (partition 2 (range 100000))))
> y (assoc x -1 -1)]
> [(doDiff x x)
> (doDiff x x1)
> (doDiff x y)])
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.