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

欢迎!有关此功能的更多信息,请参阅关于页面。

0
ClojureScript

通过使用{{goog.object/forEach}},以及直接互操作正则表达式检查,可以在1.14至1.77之间提高JavaScript对象的打印速度。

7 个答案

0

评论由:mfikes发表

`
加速摘要

    Engine  small, medium, with sub-object
        V8: 1.42, 1.31, 1.19

SpiderMonkey: 1.14, 1.48, 1.41
JavaScriptCore: 1.48, 1.58, 1.62

   Nashorn: 1.27, 1.36, 1.20
ChakraCore: 1.49, 1.77, 1.77

之前

与V8进行基准测试
[obj (js-obj "a" 1 "b" 2)], (pr-str obj), 1000次运行,74毫秒
[obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6)], (pr-str obj), 1000次运行,84毫秒
[sub-obj (js-obj "g" 7 "h" 8 "i" 9 "j" 10) obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6 "s" sub-obj)], (pr-str obj), 1000次运行,75毫秒

与SpiderMonkey进行基准测试
[obj (js-obj "a" 1 "b" 2)], (pr-str obj), 1000次运行,95毫秒
[obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6)], (pr-str obj), 1000次运行,92毫秒
[sub-obj (js-obj "g" 7 "h" 8 "i" 9 "j" 10) obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6 "s" sub-obj)], (pr-str obj), 1000次运行,134毫秒

与JavaScriptCore进行基准测试
[obj (js-obj "a" 1 "b" 2)], (pr-str obj), 1000次运行,46毫秒
[obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6)], (pr-str obj), 1000次运行,41毫秒
[sub-obj (js-obj "g" 7 "h" 8 "i" 9 "j" 10) obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6 "s" sub-obj)], (pr-str obj), 1000次运行,55毫秒

与Nashorn进行基准测试
[obj (js-obj "a" 1 "b" 2)], (pr-str obj), 1000次运行,1228毫秒
[obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6)], (pr-str obj), 1000次运行,1048毫秒
[sub-obj (js-obj "g" 7 "h" 8 "i" 9 "j" 10) obj (js-obj "a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6 "s" sub-obj)], (pr-str obj), 1000次运行,620毫秒

与ChakraCore进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,55毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,76毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,129毫秒

之后

与V8进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,52毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,64毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,63毫秒

与SpiderMonkey进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,83毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,62毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,95毫秒

与JavaScriptCore进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,31毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,26毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,34毫秒

与Nashorn进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,970毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,769毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,518毫秒

与ChakraCore进行基准测试
对象(obj) [{"a": 1, "b": 2}], (pr-str obj), 1000次运行,37毫秒
对象(obj) [{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6}], (pr-str obj), 1000次运行,43毫秒
子对象(sub-obj) [{"g": 7, "h": 8, "i": 9, "j": 10}, obj, {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "s": sub-obj}], (pr-str obj), 1000次运行,73毫秒
`

0
答者:

评论由:mfikes发表

添加了CLJS-2342-2.patch,该补丁基于当前主分支更新。

0
答者:

评论由:mfikes发表

CLJS-2342-3.patch基于当前主分支更新。

0
答者:

评论由:mfikes发表

CLJS-2342-4.patch进行更新。

0
答者:

评论由:mfikes发表

CLJS-2342-4.patch已添加到补丁模板(i)

0

评论由:mfikes发表

CLJS-2342-4.patch 通过CI和Canary测试(/)

0
参考资料: https://clojure.atlassian.net/browse/CLJS-2342 (由mfikes报告)
...