Created
February 6, 2020 18:14
-
-
Save caioaao/08fc6ed2b5e45cd146514a4f8e4257b7 to your computer and use it in GitHub Desktop.
Testing garbage collection of keywords
This file contains hidden or 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
(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