Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created July 14, 2010 04:37
Show Gist options
  • Save swannodette/475030 to your computer and use it in GitHub Desktop.
Save swannodette/475030 to your computer and use it in GitHub Desktop.
(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