Created
May 28, 2010 20:16
-
-
Save nathell/417669 to your computer and use it in GitHub Desktop.
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
(ns mmu | |
(:gen-class) | |
(:use [clojure.contrib duck-streams])) | |
(defn gc [] | |
(dotimes [_ 4] (System/gc))) | |
(defn used-memory [] | |
(let [runtime (Runtime/getRuntime)] | |
(gc) | |
(- (.totalMemory runtime) (.freeMemory runtime)))) | |
(defn measure [f] | |
(let [before (used-memory) | |
_ (def foo (with-in-reader f (read))) | |
after (used-memory)] | |
(- after before))) | |
(defn -main [f] | |
(println "Approximate memory usage:" (measure f))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment