Skip to content

Instantly share code, notes, and snippets.

@caioaao
Created February 6, 2020 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caioaao/08fc6ed2b5e45cd146514a4f8e4257b7 to your computer and use it in GitHub Desktop.
Save caioaao/08fc6ed2b5e45cd146514a4f8e4257b7 to your computer and use it in GitHub Desktop.
Testing garbage collection of keywords
(ns leak-test.core
(:gen-class))
(def alphanumerics (concat (map char (range (int \A) (inc (int \Z))))
(range 0 10)))
(defn random-alphanumeric-string [len]
"Generates a pseudo-random alphanumeric string"
(apply str (repeatedly len #(rand-nth alphanumerics))))
(defn run-op [op secs]
(let [start (System/nanoTime)]
(while (< (/ (- (System/nanoTime) start) 1e9) secs)
(op))))
;; running on repl: (run-op #(keyword (random-alphanumeric-string 10) (random-alphanumeric-string 10)) 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment