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
--[[ | |
This is an example of a wrk/wrk2 script to dynamically generate a range of GET requests for load testing. | |
you can run it by tying something similar to the following | |
./wrk -t15 -c 15 -d 600s -R1 -s order-query.lua http://localhost:8080 | |
NOTE: Noticed that the requests are dynamically generated once, given to all the threads | |
i.e you see request-a t times, then request-b t times. | |
Ideally i'd like each thread to send a dynamically generated request for each request, | |
What I see now is the group of threads getting a dynamically generated request. |
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
(defn print-threads [& {:keys [headers pre-fn] | |
:or {pre-fn identity}}] | |
(let [thread-set (keys (Thread/getAllStackTraces)) | |
thread-data (mapv bean thread-set) | |
headers (or headers (-> thread-data first keys))] | |
(clojure.pprint/print-table headers (pre-fn thread-data)))) | |
(defn print-threads-str [& args] | |
(with-out-str (apply print-threads args))) |
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
;; Write a function that takes a string and does a partial replacement on the string. | |
;; By partial replacement, I mean if the string is 3 characters or more replace all the | |
;; characters (except the first and last with X), if the string is less than 3 replace | |
;; with all characters with X | |
;; E.g | |
;; (partial-replacement "IamASecretPassword") => "IXXXXXXXXXXXXXXXXd" | |
;; (partial-replacement "YES") => "YXS" | |
;; (partial-replacement "NO") => "XX" | |