|
196 | 196 |
|
197 | 197 | (defn -main
|
198 | 198 | [& [root & args]]
|
199 |
| - (jdbc/with-db-connection [db (sqlite/db-spec ":memory:")] |
200 |
| - (let [outputs (atom [])] |
201 |
| - (doseq [args (or (->> args |
202 |
| - (partition-by #(= % "--")) |
203 |
| - (map-indexed vector) |
204 |
| - (filter (comp even? first)) |
205 |
| - (map second) |
206 |
| - (seq)) |
207 |
| - [[]])] ; always do one iteration |
208 |
| - (let [{:keys [options arguments errors summary]} (parse-opts args options) |
209 |
| - tree-to-test (atom {}) |
210 |
| - results (atom [])] |
211 |
| - (cond |
212 |
| - (or (= "-h" root) |
213 |
| - (= "--help" root) |
214 |
| - (nil? root) |
215 |
| - (:help options)) (exit 0 (usage summary)) |
216 |
| - (not= (count arguments) 0) (exit 1 (usage summary)) |
217 |
| - errors (exit 1 (error-msg errors))) |
218 |
| - (let [backend (case (:backend options) |
219 |
| - "testing" (core/->TestingBackend) |
220 |
| - "redis" (do (redis/start-expiry-thread!) |
221 |
| - (redis/->RedisBackend)) |
222 |
| - "sqlite" (do (sqlite/ensure-schema db) |
223 |
| - (sqlite/->SQLiteBackend db))) |
224 |
| - delete-xform (case (:delete-pattern options) |
225 |
| - "forward" identity |
226 |
| - "reverse" reverse |
227 |
| - "shuffle" shuffle |
228 |
| - "zero" #(repeat (count %) 0.0)) |
229 |
| - [tree-name structure] |
230 |
| - (case (:data-structure options) |
231 |
| - "b-tree" ["b-tree" (core-b-tree (:tree-width options) backend)] |
232 |
| - "fractal" ["fractal" (msg-b-tree (:tree-width options) backend)] |
233 |
| - "sorted-set" ["sorted-set" (sorted-set-repr)]) |
234 |
| - flush-freq (:flush-freq options) |
235 |
| - codename (str tree-name |
236 |
| - "__flush_" |
237 |
| - flush-freq |
238 |
| - "__b_" |
239 |
| - (:tree-width options) |
240 |
| - "__" |
241 |
| - (:backend options) |
242 |
| - "__n_" |
243 |
| - (:num-operations options) |
244 |
| - "__del_" |
245 |
| - (:delete-pattern options))] |
246 |
| - (doseq [ds (generate-test-datasets) |
247 |
| - :let [codename (str codename |
248 |
| - "_" |
249 |
| - (:name ds)) |
250 |
| - out (create-output-dir |
251 |
| - root |
252 |
| - codename) |
253 |
| - _ (println "Doing" codename) |
254 |
| - bench-res (benchmark (:num-operations options) ds flush-freq structure out delete-xform)]] |
255 |
| - (swap! results conj |
256 |
| - {:tree tree-name |
257 |
| - :ds (:name ds) |
258 |
| - :freq flush-freq |
259 |
| - :n (:num-operations options) |
260 |
| - :b (:tree-width options) |
261 |
| - :delete-pattern (:delete-pattern options) |
262 |
| - :results bench-res})) |
| 199 | + (let [outputs (atom [])] |
| 200 | + (doseq [args (or (->> args |
| 201 | + (partition-by #(= % "--")) |
| 202 | + (map-indexed vector) |
| 203 | + (filter (comp even? first)) |
| 204 | + (map second) |
| 205 | + (seq)) |
| 206 | + [[]])] ; always do one iteration |
| 207 | + (let [{:keys [options arguments errors summary]} (parse-opts args options) |
| 208 | + tree-to-test (atom {}) |
| 209 | + results (atom [])] |
| 210 | + (cond |
| 211 | + (or (= "-h" root) |
| 212 | + (= "--help" root) |
| 213 | + (nil? root) |
| 214 | + (:help options)) (exit 0 (usage summary)) |
| 215 | + (not= (count arguments) 0) (exit 1 (usage summary)) |
| 216 | + errors (exit 1 (error-msg errors))) |
| 217 | + (let [backend (case (:backend options) |
| 218 | + "testing" (core/->TestingBackend) |
| 219 | + "redis" (do (redis/start-expiry-thread!) |
| 220 | + (redis/->RedisBackend)) |
| 221 | + "sqlite" (sqlite/->SQLiteBackend |
| 222 | + (sqlite/find-or-create-db "/tmp/yolo.sqlite"))) |
| 223 | + delete-xform (case (:delete-pattern options) |
| 224 | + "forward" identity |
| 225 | + "reverse" reverse |
| 226 | + "shuffle" shuffle |
| 227 | + "zero" #(repeat (count %) 0.0)) |
| 228 | + [tree-name structure] |
| 229 | + (case (:data-structure options) |
| 230 | + "b-tree" ["b-tree" (core-b-tree (:tree-width options) backend)] |
| 231 | + "fractal" ["fractal" (msg-b-tree (:tree-width options) backend)] |
| 232 | + "sorted-set" ["sorted-set" (sorted-set-repr)]) |
| 233 | + flush-freq (:flush-freq options) |
| 234 | + codename (str tree-name |
| 235 | + "__flush_" |
| 236 | + flush-freq |
| 237 | + "__b_" |
| 238 | + (:tree-width options) |
| 239 | + "__" |
| 240 | + (:backend options) |
| 241 | + "__n_" |
| 242 | + (:num-operations options) |
| 243 | + "__del_" |
| 244 | + (:delete-pattern options))] |
| 245 | + (doseq [ds (generate-test-datasets) |
| 246 | + :let [codename (str codename |
| 247 | + "_" |
| 248 | + (:name ds)) |
| 249 | + out (create-output-dir |
| 250 | + root |
| 251 | + codename) |
| 252 | + _ (println "Doing" codename) |
| 253 | + bench-res (benchmark (:num-operations options) ds flush-freq structure out delete-xform)]] |
| 254 | + (swap! results conj |
| 255 | + {:tree tree-name |
| 256 | + :ds (:name ds) |
| 257 | + :freq flush-freq |
| 258 | + :n (:num-operations options) |
| 259 | + :b (:tree-width options) |
| 260 | + :delete-pattern (:delete-pattern options) |
| 261 | + :results bench-res})) |
263 | 262 | ;(println "results")
|
264 | 263 | ;(clojure.pprint/pprint @results)
|
265 |
| - (swap! outputs conj (template-one-sheet @results))))) |
266 |
| - (excel/render-to-file |
267 |
| - "template_benchmark.xlsx" |
268 |
| - (.getPath (File. root "analysis.xlsx")) |
269 |
| - {"SingleDS" |
270 |
| - (map-indexed (fn [i s] |
271 |
| - (assoc s :sheet-name (str "Trial " (inc i)))) |
272 |
| - @outputs)})))) |
| 264 | + (swap! outputs conj (template-one-sheet @results))))) |
| 265 | + (excel/render-to-file |
| 266 | + "template_benchmark.xlsx" |
| 267 | + (.getPath (File. root "analysis.xlsx")) |
| 268 | + {"SingleDS" |
| 269 | + (map-indexed (fn [i s] |
| 270 | + (assoc s :sheet-name (str "Trial " (inc i)))) |
| 271 | + @outputs)}))) |
0 commit comments