Last active
August 19, 2024 22:21
-
-
Save akosiaris/a643e4cdd389fbf0bb81468547ade07e to your computer and use it in GitHub Desktop.
Crude memory accounting patch for endless-ships/parser.clj
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
--- a/src/clj/endless_ships/parser.clj | |
+++ b/src/clj/endless_ships/parser.clj | |
@@ -50,8 +50,12 @@ | |
(->> files | |
(mapcat (fn [file] | |
(let [filename (.getName file) | |
- _ (println (format "parsing %s..." filename)) | |
- objects (-> file slurp (str "\n") parse)] | |
+ filesize (.length file) | |
+ usedMem (float (/ (- (-> (java.lang.Runtime/getRuntime) (.totalMemory)) (-> (java.lang.Runtime/getRuntime) (.freeMemory))) 1024)) | |
+ _ (println (format "parsing: %s. Size: %s. Used memory before parse: %s" filename filesize usedMem)) | |
+ objects (-> file slurp (str "\n") parse) | |
+ usedMem2 (float (/ (- (-> (java.lang.Runtime/getRuntime) (.totalMemory)) (-> (java.lang.Runtime/getRuntime) (.freeMemory))) 1024)) | |
+ _ (println (format "Used memory after parse: %s" usedMem2))] | |
(map #(assoc-in % [2 "file"] filename) objects)))) | |
doall))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment