 
 ;;;; TODO
 ;; * Gather results (incl. redis-benchmark) and graph for README.
+;; * Tweak client (esp. protocol design) in response to results.
 
 (defn make-benching-options
-  [& {:keys [requests clients data-size carmine-pool carmine-spec
+  [{:keys [requests clients data-size carmine-pool carmine-spec
              clj-redis-pool accession-spec] :as opts}]
   (let [merged-opts (merge {:requests  10000
                             :clients   5


(comment
  ;; Define pools and stuff only ONCE
  (def std-opts
    (make-benching-options :carmine-spec   (carmine/make-conn-spec)
                           :carmine-pool   (carmine/make-conn-pool)
                           :accession-spec (accession/connection-map)
                           :clj-redis-pool (clj-redis/init)))

  ;; Ad hoc
  (bench-carmine       (assoc std-opts :requests 1000 :clients 1 :data-size 10))
  (bench-accession     (assoc std-opts :requests 1000 :clients 1 :data-size 10))
  (bench-clj-redis     (assoc std-opts :requests 1000 :clients 1 :data-size 10))
  (bench-redis-clojure (assoc std-opts :requests 1000 :clients 1 :data-size 10))

  ;; Comparisons
  (bench-and-compare-clients
   (assoc std-opts :requests 1000 :clients 1 :data-size 10))

  ;; Deprecated
  ;; ([:Carmine 1.0] [:clj-redis 1.51] [:redis-clojure 1.72] [:Accession 4.19])
  ;; ([:Carmine 1.0] [:clj-redis 1.58] [:redis-clojure 1.7]  [:Accession "DNF"])
  ;; ([:Carmine 1.0] [:clj-redis 1.36] [:redis-clojure 1.43] [:Accession 2.47])
  )
       (/ (double (- (System/nanoTime) start-time#)) 1000000.0)
       (catch Exception e# (println "Exception: " e#) "DNF"))))

(comment (time-requests (make-benching-options {:requests 9
                                                :clients  3})
                        (Thread/sleep 1000)))

(defn bench-redis-clojure
  [{:keys [data-key data] :as opts}]
  (println "Benching redis-clojure...")
  {:ping (time-requests opts (redis-clojure/with-server {}
                               (redis-clojure/ping)))
   :set  (time-requests opts (redis-clojure/with-server {}
                               (redis-clojure/set data-key data)))
   :get  (time-requests opts (redis-clojure/with-server {}
                               (redis-clojure/get data-key)))})

(defn bench-clj-redis
  [{:keys [data-key data] db :clj-redis-pool :as opts}]
  (println "Benching clj-redis...")
  {:ping (time-requests opts (clj-redis/ping db))
   :set  (time-requests opts (clj-redis/set db data-key data))
   :get  (time-requests opts (clj-redis/get db data-key))})

(defn bench-accession
  [{:keys [data-key data] spec :accession-spec :as opts}]
  (println "Benching Accession...")
  {:ping (time-requests opts (accession/with-connection spec
                               (accession/ping)))
   :set  (time-requests opts (accession/with-connection spec
                               (accession/set data-key data)))
   :get  (time-requests opts (accession/with-connection spec
                               (accession/get data-key)))})

(defn bench-carmine
  [{:keys [data-key data] pool :carmine-pool spec :carmine-spec :as opts}]
  (println "Benching Carmine...")
  {:ping (time-requests opts (carmine/with-conn pool spec
                               (carmine/ping)))
   :set  (time-requests opts (carmine/with-conn pool spec
                               (carmine/set data-key data)))
   :get  (time-requests opts (carmine/with-conn pool spec
                               (carmine/get data-key)))})

(defn- sort-times
  "{:a 447.38 :b \"DNF\" :c 112.77 :d 374.47 :e 374.47} =>
