<commit_before>(ns ws.client.ws_client
  (:gen-class)
  (:require [clj-http.client :as http]
            [clojure.java.io :as io]))

(declare run-load-test)
(declare send-requests)
(declare get-formatted-date)

(defn -main
  [url numThreads requests-per-thread log-path]
  (run-load-test url (Integer/parseInt numThreads) (Integer/parseInt requests-per-thread) log-path)
  (System/exit 0))


(defn run-load-test
  "Execute load test against given URL. Blocks while performing test."
  ([url num-threads requests-per-thread log-path]
    (println "\tStarting load test => " url)
    (println "\t\t => log:" log-path)
    (println "\t\t => threads:" num-threads)
    (println "\t\t => requests-per-thread:" requests-per-thread)
    ; response-log-agent: used for sending response logs to and serializing them to output
    (let [response-log-agent (agent -1)]
	    (with-open [log-writer (io/writer log-path)]
        ; hand write some JSON 
        (.write log-writer (str "{"))
        (.write log-writer (str "\n\t\"request\" : \"" url "\","))
        (.write log-writer (str "\n\t\"start_time\" : \"" (get-formatted-date (new java.util.Date)) "\","))
        (.write log-writer (str "\n\t\"num_threads\" : " num-threads ","))
        (.write log-writer (str "\n\t\"requests-per-thread\" : " requests-per-thread ","))
        (.write log-writer (str "\n\t\"requests\" : [\n"))
        ; start the load test and output logs into the JSON
	      (http/with-connection-pool {:timeout 500 :threads 20 :insecure? false :default-per-route 20}
	        (let [futures (doall (for [i (range num-threads)]
	                             (future
	                               ;(println "send-requests starting in thread: " (Thread/currentThread))<commit_msg>the client was hardcoded at a max of 20 connections … fixed to use thread count now<commit_after>(ns ws.client.ws_client
  (:gen-class)
  (:require [clj-http.client :as http]
            [clojure.java.io :as io]))

(declare run-load-test)
(declare send-requests)
(declare get-formatted-date)

(defn -main
  [url numThreads requests-per-thread log-path]
  (run-load-test url (Integer/parseInt numThreads) (Integer/parseInt requests-per-thread) log-path)
  (System/exit 0))


(defn run-load-test
  "Execute load test against given URL. Blocks while performing test."
  ([url num-threads requests-per-thread log-path]
    (println "\tStarting load test => " url)
    (println "\t\t => log:" log-path)
    (println "\t\t => threads:" num-threads)
    (println "\t\t => requests-per-thread:" requests-per-thread)
    ; response-log-agent: used for sending response logs to and serializing them to output
    (let [response-log-agent (agent -1)]
	    (with-open [log-writer (io/writer log-path)]
        ; hand write some JSON 
        (.write log-writer (str "{"))
        (.write log-writer (str "\n\t\"request\" : \"" url "\","))
        (.write log-writer (str "\n\t\"start_time\" : \"" (get-formatted-date (new java.util.Date)) "\","))
        (.write log-writer (str "\n\t\"num_threads\" : " num-threads ","))
        (.write log-writer (str "\n\t\"requests-per-thread\" : " requests-per-thread ","))
        (.write log-writer (str "\n\t\"requests\" : [\n"))
        ; start the load test and output logs into the JSON
	      (http/with-connection-pool {:timeout 500 :threads num-threads :insecure? false :default-per-route num-threads}
	        (let [futures (doall (for [i (range num-threads)]
	                             (future
	                               ;(println "send-requests starting in thread: " (Thread/currentThread))
{'fraction_non_alphanumeric': 0.16146123814835472, 'fraction_numerical': 0.004461795872838818, 'mean_word_length': 2.6416243654822336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4886526', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1115, 'n_words': 317}