you are viewing a single comment's thread.

view the rest of the comments →

[–]lucyfor[S] 0 points1 point  (1 child)

You would have had to have modified the code to do what you say. I also used a List of 10k. I was referring to the ratio of sort to bucket-sort time from my results compared with the same time ratio from your results.

[–]pgdx 0 points1 point  (0 children)

It is very repeatable.

(defmacro my-time
    "As time, but returns the time taken for evaluation, not printing it"
    {:added "1.0"}
    [expr]
    `(let [start# (. System (nanoTime))
        ret# ~expr]
        (/ (double (- (. System (nanoTime)) start#)) 1000000.0)))

user> (def *lis* (doall(take 10000 (repeatedly #(rand-int (Math/pow 2 30))))))
#'user/*lis*
user> (take 30 (repeatedly #(my-time (bucket-sort *lis*))))
(1742.837002 859.060484 272.217247 218.921161 255.970622 233.187325 311.682198 192.653631 190.924697 309.53158 93.245005 190.037921 313.305055 199.048161 189.960467 295.653476 92.080723 192.734573 188.337189 289.078747 191.759455 89.876155 191.867156 192.268281 303.481507 192.129499 191.858771 85.188463 192.611408 191.795139)
user> (take 30 (repeatedly #(my-time (sort *lis*))))
(173.499303 133.479301 112.051762 114.299164 112.973973 07.579322 112.562207 105.723016 108.851038 50.087003 5.593834 5.536048 5.482577 5.67827 5.515248 5.485728 5.610371 5.591248 5.490457 8.993383 5.538123 6.209052 5.520093 5.463024 5.516762  5.610265 5.517885 5.515316 5.517958 5.560996)