Created
December 9, 2011 02:29
-
-
Save sunng87/1449860 to your computer and use it in GitHub Desktop.
client code for benchmarking slacker
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
(ns slackerbench.core | |
(:use [slacker.client]) | |
(:import [java.util.concurrent Executors TimeUnit]) | |
(:gen-class)) | |
(defn -main [& args] | |
(def host (first args)) | |
(def total-connections (Integer/valueOf (nth args 2))) | |
(def scp (slackerc-pool host 2104 | |
:max-active total-connections)) | |
(def thread-pool (Executors/newFixedThreadPool | |
(Integer/valueOf (nth args 3)))) | |
(def total-calls (Integer/valueOf (second args))) | |
(defremote scp rand-ints) | |
(time | |
(do | |
(.invokeAll thread-pool (take total-calls (repeat (fn [] (rand-ints 5))))) | |
(.shutdown thread-pool) | |
(.awaitTermination thread-pool -1 TimeUnit/SECONDS))) | |
(System/exit 0)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
lein run host total-requests connections threads
Currently, it uses synchronous client so you are suggested to set connections == threads