Last active
February 5, 2016 00:18
-
-
Save junegunn/1d53b795b22fe9939dc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn recreate-table! | |
[] | |
(doto C | |
(admin/drop-table! :test-table) | |
(admin/create-table :test-table :d))) | |
(defn increment | |
[max] | |
(core/with-table C [t :test-table] | |
(core/inc t (rand-int max) {:d:foo 1}))) | |
(doseq [num-threads [1 2 4 8 16 32 64 96]] | |
(recreate-table!) | |
(let [num-records 10000 | |
num-iterations 500000 | |
pool (java.util.concurrent.Executors/newFixedThreadPool num-threads) | |
job (partial increment num-records) | |
now (System/currentTimeMillis)] | |
(dotimes [_ num-iterations] | |
(.submit pool job)) | |
(log/info "Waiting") | |
(doto pool | |
.shutdown | |
(.awaitTermination Long/MAX_VALUE TimeUnit/SECONDS)) | |
(let [elapsed (- (System/currentTimeMillis) now) | |
tps (/ num-iterations elapsed 0.001)] | |
(printf "Num threads: %d, Elapsed time: %d ms, TPS: %d\n" | |
num-threads elapsed (int tps))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment