Title / Description
Code (defn run [nvecs nitems nthreads niters] "ffffffffffffffffff" (let [vec-refs (vec (map (comp ref vec) (partition nitems (range (* nvecs nitems))))) swap #(let [v1 (rand-int nvecs) v2 (rand-int nvecs) i1 (rand-int nitems) i2 (rand-int nitems)] (dosync (let [temp (nth @(vec-refs v1) i1)] (alter (vec-refs v1) assoc i1 (nth @(vec-refs v2) i2)) (alter (vec-refs v2) assoc i2 temp)))) report #(do (prn (map deref vec-refs)) (println "Distinct:" (count (distinct (apply concat (map deref vec-refs))))))] (report) (dorun (apply pcalls (repeat nthreads #(dotimes [_ niters] (swap))))) (report))) (run 100 10 10 100000)
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code