I think you should move the future inside do times, since then you’ll get a 
future for each write.
Also, I don’t think you need to put your json-template in an atom:

(ns jsonworker.foo
  (:require [cheshire.core :refer :all ]))


(defn parse-json
  [file-loc]
  (parse-stream (clojure.java.io/reader file-loc)))

(def json-template (parse-json "resources/foo.json"))

(def fol-location "/tmp/json_output")

(defn update-individual [json-string]
  (assoc-in json-string ["someInfo" "moreInfo"]
            (rand-nth  (range 1000 1000000))))

(defn gen-files [folder-loc text]
  (spit (str folder-loc "/newfile_" (rand-int 1e7)) text))

(defn run-me [x]
  (dotimes [_ x]
   (future
     (gen-files fol-location (update-individual json-template)))))

> On 20 Aug 2016, at 19:49, Abhinav Gogna <abhigo...@gmail.com> wrote:
> 
> Hello,
> 
> I am trying to generate lot of files using futures but it hasn't sped up the 
> process that hoped for. Here is the code I am using. Can someone point what I 
> am doing wrong?
> 
> (ns jsonworker.core
>   (:require [cheshire.core :refer :all ]))
> 
> 
> (defn parse-json
>   [file-loc]
>   (parse-stream (clojure.java.io/reader file-loc)))
> 
> (def json-template (atom (parse-json "resources/individual_1918203.json")))
> 
> (def fol-location "/Users/json/json_output")
> 
> (defn update-individual [json-string]
>   (assoc-in json-string ["someInfo" "moreInfo"]
>             (rand-nth  (range 1000 1000000))))
> 
> 
> (defn gen-files [folder-loc text]
>   (spit (str folder-loc "/newfile_" (rand-int 1e7)) text))
> 
> 
> (defn run-me [x]
>   (future  
>     (dotimes [_ x]
>       (swap! json-template update-individual)
>       (gen-files fol-location @json-template))))
> 
> 
> Thanks!
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to