Skip to content

Commit

Permalink
First crack at exploring reported perf issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lread committed May 1, 2021
1 parent 8296f42 commit 4d16f43
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cljfmt/deps.edn
@@ -0,0 +1,4 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
rewrite-clj/rewrite-clj {:mvn/version "1.0.605-alpha" }
criterium/criterium {:mvn/version "0.4.6"}}}
21 changes: 21 additions & 0 deletions cljfmt/perf.clj
@@ -0,0 +1,21 @@
(ns perf
(:require [cljfmt.core :as cljfmt]
[criterium.core :as criterium]
[rewrite-clj.parser :as p]))

(def sample1 "https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/cd64d430d83cb068d4a0a011beeded3beb791201/src/clojure_lsp/handlers.clj")

(defn -main [[test-id]]
(case test-id
"reformat-string"
(let [s (slurp sample1)]
(println "benchmarking reformat-string")
(criterium/with-progress-reporting (criterium/bench (cljfmt/reformat-string s) :verbose)))

"reformat-form"
(let [s (slurp sample1)
n (p/parse-string-all s)]
(println "benchmarking reformat-form")
(criterium/with-progress-reporting (criterium/bench (cljfmt/reformat-form n) :verbose)))))

(-main *command-line-args*)

0 comments on commit 4d16f43

Please sign in to comment.