From de21bc98b04e8eb55b9a0448cda311f6c52f89f6 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Mon, 23 Aug 2010 20:04:44 -0400 Subject: add perf. test --- test/dumpfm/load_test.clj | 25 ++++++++++++++++++++++++- test/dumpfm/millstone.clj | 8 +++++--- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'test/dumpfm') diff --git a/test/dumpfm/load_test.clj b/test/dumpfm/load_test.clj index 2410032..49069e9 100644 --- a/test/dumpfm/load_test.clj +++ b/test/dumpfm/load_test.clj @@ -56,6 +56,25 @@ limit 100 :params params :method "GET"))) +(defn rand-nick [] + (:nick (rand-elt userlist))) + +(defn load-profile [] + (do-request! (str "/" (rand-nick)) + :label "profile")) + +(defn load-popular-profile [] + (do-request! (str "/" (rand-nick)) + :label "popular-profile")) + +(defn load-popular-popular [] + (do-request! (str "/" (rand-elt ["ryder" "jeanette"]) "/popular") + :label "popular-popular")) + +(defn load-popular [] + (do-request! (str "/" (rand-nick) "/popular") + :label "popular")) + (defn chat [] (do-request! "/test/chat")) @@ -75,11 +94,15 @@ limit 100 :method "POST"))) (def test-spec {:server "http://localhost:8080" - :clients 200 + :clients 75 :requests 10000 :max-latency 1000 :setup-func login-client :funcs [[55 refresh] + [10 load-popular] + [10 load-profile] + [3 load-popular-popular] + [3 load-popular-profile] [3 chat] [5 post-msg]] :frequency 1 diff --git a/test/dumpfm/millstone.clj b/test/dumpfm/millstone.clj index d972a88..2c1cf4d 100644 --- a/test/dumpfm/millstone.clj +++ b/test/dumpfm/millstone.clj @@ -37,6 +37,7 @@ (= (:code resp) 200)) (defnk do-request! [path + :label nil :params nil :method "GET"] (let [[ms resp] (with-timing @@ -49,6 +50,7 @@ (log (format "Exception for %s - %s" path (.getMessage e))) {:code "?" :msg "EXCEPTION"}))) result {:path path + :label (or label path) :ms ms :error (if (success? resp) nil [(:code resp) (:msg resp)])}] (if (= (rand-int 100) 1) @@ -80,14 +82,14 @@ (/ (count results) (/ elapsed-ms 1000)) (:clients spec))) (let [avg-in-req (/ (sum (map :ms results)) (:clients spec))] - (log (format "\nTime spent in requests per worker : %.02fs (%.02f%%)" + (log (format "\nTime spent in requests (per worker): %.02fs (%.02f%%)" (/ avg-in-req 1000) (* (/ avg-in-req elapsed-ms) 100)))) - (doseq [[path rs] (group-by :path results)] + (doseq [[label rs] (group-by :label results)] (let [nums (map :ms rs) errors (filter identity (map :error rs))] (log (format "\n%s:\n#: %s\nmin: %.02f ms\navg: %.02f ms\nmax: %.02f ms" - path + label (count rs) (apply min nums) (avg nums) -- cgit v1.2.3-70-g09d2