2024 Clojure 状况调查! 中分享您的想法。

欢迎!请参阅 关于 页面了解如何操作的更多信息。

0
ClojureScript
clojure.core/distinct 的当前实现使用持久化集合。此补丁通过使用临时映射而不是持久化集合提高了性能,性能提高了大约 10%-33%。镜像 Clojure 任务 CLJ-2090


10 个元素
(reduce + 0 (distinct coll))     12.360220502805724 µs => 9.504153281757874 µs (-23%)
(transduce (distinct) + 0 coll)  7.689213711227641 µs => 5.3549045227207 µs (-30%)
100 个元素
(reduce + 0 (distinct coll))     136.43424283765356 µs => 106.66990187713321 µs (-21%)
(transduce (distinct) + 0 coll)  73.05427319211107 µs => 48.737280701754386 µs (-33%)
1000 个元素
(reduce + 0 (distinct coll))     1.1207102908277415 ms => 919.8952205882359 µs (-17%)
(transduce (distinct) + 0 coll)  677.2834912043312 µs => 482.79681467181547 µs (-28%)
10000 个元素
(reduce + 0 (distinct coll))     4.777295238095228 ms => 4.3203448275862115 ms (-9%)
(transduce (distinct) + 0 coll)  2.889020114942531 ms => 2.44890487804879 ms (-15%)


基准测试代码:https://gist.github.com/tonsky/258c3d715e6a485522f7ba5e663624fd

2 答案

0

评论者:mfikes

cljs-1881-transient-in-distinct.patch 无效

0
参考:https://clojure.atlassian.net/browse/CLJS-1881 (报告人:tonsky)
...