Permalink
Browse files

Added more samples

  • Loading branch information...
1 parent 5f7c06f commit 5547ed41ecd6fcd1b7ff96240352e6dfc16597db @levand committed Aug 25, 2011
@@ -0,0 +1,16 @@
+(ns histograms-by-operation
+ (:use [incanter core stats charts])
+ (:require [clojure.pprint :as pp]))
+
+(println (count user/*samples*))
+(pp/pprint (first user/*samples*))
+
+
+(def samples
+ ($where {:latency {:$lt 1000}} (dataset (keys (first user/*samples*)) user/*samples*)))
+
+(def operations ($group-by [:label] samples))
+
+(doseq [[{label :label} ds] operations]
+ (with-data ds
+ (view (histogram ($ :latency) :nbins 50 :title label))))
@@ -0,0 +1,91 @@
+(ns perf-by-thread
+ (:use [incanter core stats charts])
+ (:require [clojure.pprint :as pp]))
+
+(pp/pprint (first user/*samples*))
+
+(defn normalize-samples [samples]
+ (let [origin (reduce min (map :start-time samples))]
+ (map #(update-in % [:start-time] - origin) samples)))
+
+(def my-samples (normalize-samples user/*samples*))
+
+(def samples (dataset (keys (first my-samples)) my-samples))
+
+(def operations ($group-by [:label] samples))
+
+
+(defn is-valid-set
+ "Determines if this set has enough data to care about"
+ [[{groups-label :group-threads} ds]]
+ (< 5 (count (:rows ds))))
+
+
+(defn calc-throughput1
+ "Calculates throughput based on the sum of latencies"
+ [threads ds]
+ (let [aggregate-latency (reduce + ($ :latency ds))
+ estimated-time (/ aggregate-latency threads)
+ ms-per-record (/ estimated-time (count (:rows ds)))
+ throughput-hr (/ (* 1000.0 60 60) ms-per-record)]
+ throughput-hr))
+
+
+(defn build-meta-ds
+ [all-data]
+ (map (fn [[{threads :group-threads} ds]]
+ (with-data ds
+ (let [quantiles (quantile ($ :latency) :probs [0.999 0.99 0.95 0.9])]
+ {:threads threads
+ :throughput (calc-throughput1 threads $data)
+ :sample-count (count (:rows $data))
+ :min-latency (reduce min ($ :latency))
+ :max-latency (reduce max ($ :latency))
+ :mean-latency (mean ($ :latency))
+ :median-latency (median ($ :latency))
+ :std-dev-latency (sd ($ :latency))
+ :percentile-999 (nth quantiles 0)
+ :percentile-99 (nth quantiles 1)
+ :percentile-95 (nth quantiles 2)
+ :percentile-90 (nth quantiles 3)
+ :error-rate (/ (count (:rows ($where {:successful {:$eq false}})))
+ (count (:rows $data)))})))
+ (filter is-valid-set ($group-by [:group-threads] all-data))))
+
+
+(defn operation-latency-chart [op-ds label]
+ (let [datamap (build-meta-ds op-ds)
+ ds ($order :threads :asc (dataset (keys (first datamap)) datamap))]
+ (with-data ds
+ (view
+ (doto (line-chart :threads :mean-latency :series-label "mean latency" :legend true :title label)
+ (add-categories :threads :median-latency :series-label "median latency")
+ (add-categories :threads :percentile-90 :series-label "90th percentile")
+ (add-categories :threads :percentile-95 :series-label "95th percentile")
+ (add-categories :threads :percentile-99 :series-label "99th percentile")
+ (add-categories :threads :percentile-999 :series-label "99.9th percentile")
+ (add-categories :threads :error-rate :series-label "Error rate")
+ (add-categories :threads :throughput :series-label "Throughput/hr")
+ )))))
+
+(defn print-summary [op-ds op-label]
+ (println "------" op-label "------")
+ (with-data op-ds
+ (let [latency ($ :latency)
+ quantiles (quantile latency :probs [0.999 0.99 0.95 0.9])]
+ (println "Load:" (reduce min ($ :group-threads)) "to" (reduce max ($ :group-threads)) "threads.")
+ (println "mean latency: " (mean latency))
+ (println "median latency: " (median latency))
+ (println "latency std deviation: " (sd latency))
+ (println "max latency: " (reduce max latency))
+ (println "min latency: " (reduce min latency))
+ (println "99.9 percentile latency" (nth quantiles 0))
+ (println "99 percentile latency" (nth quantiles 1))
+ (println "95 percentile latency" (nth quantiles 2))
+ (println "90 percentile latency" (nth quantiles 3))
+ (println "error rate" (double (/ (count (:rows ($where {:successful {:$eq false}})))
+ (count (:rows $data))))))))
+
+(doseq [[{op-label :label} op-ds] operations]
+ (print-summary op-ds op-label)
+ (operation-latency-chart op-ds op-label))
View
@@ -0,0 +1,9 @@
+;;
+
+(use '(incanter core stats charts))
+(use '(clojure pprint))
+
+(pprint (first *samples*))
+
+(println (count *samples*))
+
@@ -0,0 +1,27 @@
+(ns scatterplot-by-thread
+ (:use [incanter core stats charts])
+ (:require [clojure.pprint :as pp]))
+
+(println (nil? user/*samples*))
+
+(pp/pprint (first user/*samples*))
+
+(print (count user/*samples*))
+
+
+(def samples (dataset (keys (first user/*samples*)) user/*samples*))
+
+(def operations ($group-by [:label] samples))
+
+(defn is-valid-set
+ "Determines if this set has enough data to care about"
+ [ds]
+ (< 5 (count (:rows ds))))
+
+(doseq [[{op-label :label} op-ds] operations]
+ (if (< 5 (count (:rows op-ds)))
+ (let [chart (scatter-plot :start-time :latency :title op-label :legend true :data (dataset []))]
+ (doseq [[{g :group-threads} d] ($group-by [:group-threads] op-ds)]
+ (if (< 5 (count (:rows d)))
+ (add-points chart :start-time :latency :data d :series-label (str g " threads"))))
+ (view chart))))

0 comments on commit 5547ed4

Please sign in to comment.