beginners

2026-06-22T02:57:19.850209Z

13x slowdown is likely an issue with your code. If it was 1.3x or 1.5x that would be more realistic and possibly when language/runtime become the difference, but anything above 1.5x,.sspecially 2x slower you can almost always optimize away.

❤️ 1
rolt 2026-06-22T09:43:30.828019Z

as @tsulej said I think you're wasting a lot of time casting boxed numbers to primitives. Consider this quick benchmark:

(defn f [p] (+ (double (:x p)) (double (:y p))))
(let [p {:x 1.5 :y 2.0}] (criterium.core/quick-bench (f p)))
Evaluation count : 34459788 in 6 samples of 5743298 calls.
             Execution time mean : 13.137730 ns
    Execution time std-deviation : 1.481858 ns
   Execution time lower quantile : 12.159528 ns ( 2.5%)
   Execution time upper quantile : 15.161418 ns (97.5%)
                   Overhead used : 5.826743 ns
;; => nil
(defrecord Point [^double x ^double y])
(defn f2 [^Point p] (+ (.x p) (.y p)))
(let [p (map->Point {:x 1.5 :y 2.0})] (criterium.core/quick-bench (f2 p)))
Evaluation count : 77743386 in 6 samples of 12957231 calls.
             Execution time mean : 2.145917 ns
    Execution time std-deviation : 0.717939 ns
   Execution time lower quantile : 1.372690 ns ( 2.5%)
   Execution time upper quantile : 2.860339 ns (97.5%)
                   Overhead used : 5.826743 ns
;; => nil

❤️ 1
N S 2026-06-22T09:55:22.123259Z

wow, that's 10 time difference really. Thanks for pointing it out.