Skip to content

Commit

Permalink
bench test code reorganized
Browse files Browse the repository at this point in the history
  • Loading branch information
anfeng committed May 12, 2013
1 parent ca14624 commit 6866319
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions storm-netty/test/clj/backtype/storm/messaging/bench_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
(def task 1)
(def msg_count 100000)

(deftest test-netty-perf
(time (let [storm-conf {STORM-MESSAGING-TRANSPORT "backtype.storm.messaging.netty.Context"
STORM-MESSAGING-NETTY-BUFFER-SIZE 1024000
STORM-MESSAGING-NETTY-MAX-RETRIES 10
STORM-MESSAGING-NETTY-MIN-SLEEP-MS 1000
STORM-MESSAGING-NETTY-MAX-SLEEP-MS 5000}
context (TransportFactory/makeContext storm-conf)
server (.bind context nil port)
(defn batch-bench [context]
(let [server (.bind context nil port)
client (.connect context nil "localhost" port)]
(doseq [num (range 1 msg_count)]
(let [req_msg (str num)]
Expand All @@ -28,22 +22,19 @@
(is (= req_msg resp_msg))))
(.close client)
(.close server)
(.term context))))
(.term context)))

(deftest test-netty-perf
(time (let [storm-conf {STORM-MESSAGING-TRANSPORT "backtype.storm.messaging.netty.Context"
STORM-MESSAGING-NETTY-BUFFER-SIZE 1024000
STORM-MESSAGING-NETTY-MAX-RETRIES 10
STORM-MESSAGING-NETTY-MIN-SLEEP-MS 1000
STORM-MESSAGING-NETTY-MAX-SLEEP-MS 5000}
context (TransportFactory/makeContext storm-conf)]
(batch-bench context))))

(deftest test-zmq-perf
(time (let [storm-conf (merge (read-storm-config)
{STORM-MESSAGING-TRANSPORT "backtype.storm.messaging.zmq"})
context (TransportFactory/makeContext storm-conf)
server (.bind context nil port)
client (.connect context nil "localhost" port)]
(doseq [num (range 1 msg_count)]
(let [req_msg (str num)]
(.send client task (.getBytes req_msg))))
(doseq [num (range 1 msg_count)]
(let [req_msg (str num)
resp (.recv server 0)
resp_msg (String. (.message resp))]
(is (= req_msg resp_msg))))
(.close client)
(.close server)
(.term context))))
context (TransportFactory/makeContext storm-conf)]
(batch-bench context))))

0 comments on commit 6866319

Please sign in to comment.