;;; Python => 22.8 ms for 10 iterations of 1,000,000 elements => 2-3 ms for a single iteration
import numpy as np
my_arr = np.arange(1000000)
my_list = list(range(1000000))
%time for _ in range(10): my_arr2 = my_arr * 2
CPU times: user 14.5 ms, sys: 8.33 ms, total: 22.8 ms
Wall time: 22.8 ms
;;; Clojure - vectors & arrays => ~13 ms at best using plain arrays
(def my-array (int-array (range 1000000)))
(time
(dotimes [i 10]
(amap ^ints my-array
idx
ret
(* (int 2) (aget ^ints my-array idx)))))
"Elapsed time: 133.522233 msecs"
;; use also criterium for more objective measurement
(require '[criterium.core :as crit])
(crit/quick-bench (amap ^ints my-array
idx
ret
(* (int 2) (aget ^ints my-array idx))))
;; Evaluation count : 48 in 6 samples of 8 calls.
;; Execution time mean : 14.022060 ms
;; Execution time std-deviation : 476.098590 µs
;; Execution time lower quantile : 13.728450 ms ( 2.5%)
;; Execution time upper quantile : 14.807910 ms (97.5%)
;; Overhead used : 8.025814 ns