Last active
October 7, 2021 15:01
-
-
Save pbaille/11a4bceef813adabc23ad1c9cf607bc2 to your computer and use it in GitHub Desktop.
stress terminus 2 threads
This file contains 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
(require 'clj-http.client) | |
(def DURATION 10) | |
(def tics (atom 1)) | |
(def responses (atom [])) | |
(def start (System/currentTimeMillis)) | |
(defn rand-query [] | |
{"@type" "woql:AddTriple", | |
"woql:subject" {"@type" "woql:Node", "woql:node" (str "doc:" (gensym))}, | |
"woql:predicate" {"@type" "woql:Node", "woql:node" (str "scm:" (gensym))}, | |
"woql:object" {"@type" "woql:Node", "woql:node" (str "doc:" (gensym))}}) | |
(declare tic) | |
(defn cont [id response] | |
(when (< (- (System/currentTimeMillis) start) | |
(* DURATION 1000)) | |
#_(swap! responses conj [id response]) | |
(swap! tics inc) | |
(tic id))) | |
(defn tic [id] | |
(clj-http.client/post "https://localhost:6363/api/woql/admin/pouet" | |
{:basic-auth "admin:root" | |
:async true | |
:insecure? true, | |
:validate-hostnames false, | |
:content-type :json | |
:form-params | |
{:commit_info {:author "pierrebaille@gmail.com", :message "si je veux"}, | |
:query (rand-query)}} | |
(partial cont id) | |
(partial cont id))) | |
(tic "one") | |
(tic "two") | |
(Thread/sleep (* DURATION 1000)) | |
(println "requests per second: " | |
(float (/ @tics DURATION))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment