Skip to content

Instantly share code, notes, and snippets.

@sunng87
Created December 9, 2011 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunng87/1449860 to your computer and use it in GitHub Desktop.
Save sunng87/1449860 to your computer and use it in GitHub Desktop.
client code for benchmarking slacker
(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))
@sunng87
Copy link
Author

sunng87 commented Dec 9, 2011

Usage:
lein run host total-requests connections threads

Currently, it uses synchronous client so you are suggested to set connections == threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment