greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

Performance improvements #28

Closed greglook closed 4 years ago

greglook commented 4 years ago

After doing a bit of profiling with clj-async-profiler, I noticed that some of the new formatting rules consume more CPU than they should need to. Of a sample flame graph where reformat-form took 43.47% of the measured CPU time, that time was spent:

This means that the type rules take almost half of the CPU time, despite type definitions being a small fraction of the actual code! It would be better to consider a more targeted approach, where the form is first searched for a relevant type form, then edits are applied to just that subform. The functions in rewrite-clj.zip.subedit might be useful for this.

greglook commented 4 years ago

Largely done in 0a125ab...b86b22f.