babashka / obb

Ad-hoc ClojureScript scripting of Mac applications via Apple's Open Scripting Architecture.
Eclipse Public License 1.0
241 stars 5 forks source link

Lazy loading of occasionally needed code #23

Closed zane closed 2 years ago

zane commented 2 years ago

Loading JavaScript is expensive. Definitions needed for intermittently used features like the REPL should not be read unless that feature is being used in a particular call.

$ time nbb -e '(+ 1 2 3)'
6
nbb -e '(+ 1 2 3)'   0.18s  user 0.02s system 109% cpu 0.185 total
$ time nbb -e "(require '[clojure.pprint :as pprint])"
nbb -e "(require '[clojure.pprint :as pprint])"   0.21s  user 0.02s system 107% cpu 0.213 total