Created
July 14, 2010 04:37
-
-
Save swannodette/475030 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
(ns third-post.core | |
(:require [com.twinql.clojure.http :as http])) | |
(defn ping [] | |
(-> (http/get "http://localhost:5123" :as :string) :content)) | |
(defn multi-ping [] | |
(->> (repeatedly 16 #(ping)) | |
(apply str))) | |
(defn par-ping [] | |
(->> (repeatedly 16 #(future (ping))) | |
(pmap deref) | |
(apply str))) | |
(comment | |
;; ~450ms | |
(dotimes [_ 10] | |
(Thread/sleep 1000) | |
(time | |
(dotimes [_ 60] | |
(multi-ping)))) | |
;; ~110ms | |
(dotimes [_ 10] | |
(Thread/sleep 1000) | |
(time | |
(dotimes [_ 60] | |
(par-ping)))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment