Last active
December 31, 2015 04:49
-
-
Save pcn/7937204 to your computer and use it in GitHub Desktop.
Clojure devs recommend writing with spit. Which is really inefficient.
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
``` | |
carbon-relaj.core=> (time | |
#_=> (doseq [c (range 10000)] | |
#_=> (spit "/tmp/spit-file" (str c "\n")))) | |
"Elapsed time: 8613.006 msecs" | |
nil | |
carbon-relaj.core=> | |
carbon-relaj.core=> (time | |
#_=> (let [fname "/tmp/with-open"] | |
#_=> (with-open [wr-file (clojure.java.io/writer fname)] | |
#_=> (doseq [c (range 10000)] | |
#_=> (.write wr-file (str c "\n")))))) | |
"Elapsed time: 4.991 msecs" | |
nil | |
``` | |
There's no real surprise here, it just confirms that there's no secret sauce to | |
make writing to the file fast as long as the context of the write is to the same file :( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment