forked from mhjort/trombi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
short_summary.clj
25 lines (22 loc) · 906 Bytes
/
short_summary.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns clj-gatling.reporters.short-summary
(:require [clojure.set :refer [rename-keys]]))
(def generator
(fn [_]
{:generate identity
:as-str (fn [{:keys [ok ko]
:or {ko 0 ok 0}}]
(let [total (+ ok ko)]
(str "Total number of requests: " total
", successful: " ok
", failed: " ko ".")))}))
(def collector
(fn [_]
{:collect (fn [_ {:keys [batch]}]
(let [freqs (frequencies (mapcat #(map :result (:requests %)) batch))]
;TODO Simulation should not return nil (it should return false instead)
(rename-keys freqs {true :ok false :ko nil :ko})))
:combine #(merge-with + %1 %2)}))
(def reporter
{:reporter-key :short
:collector 'clj-gatling.reporters.short-summary/collector
:generator 'clj-gatling.reporters.short-summary/generator})