From bfa8b45e34ced3a21f79ca6d1646cfdc2e979ed6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 14 Jan 2020 17:12:57 +0100 Subject: [PATCH] sci: performance improvement --- deps.edn | 8 +++++++- sci | 2 +- src/babashka/main.clj | 4 ++-- test/babashka/profile.clj | 12 ++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/babashka/profile.clj diff --git a/deps.edn b/deps.edn index ed5def07..94654b7b 100644 --- a/deps.edn +++ b/deps.edn @@ -9,4 +9,10 @@ org.clojure/data.csv {:mvn/version "0.1.4"}, cheshire {:mvn/version "5.9.0"}} :aliases {:main - {:main-opts ["-m" "babashka.main"]}}} + {:main-opts ["-m" "babashka.main"]} + :profile + {:extra-deps + {com.clojure-goes-fast/clj-async-profiler {:mvn/version "0.4.0"}} + :extra-paths ["test"] + :jvm-opts ["-Djdk.attach.allowAttachSelf"] + :main-opts ["-m" "babashka.profile"]}}} diff --git a/sci b/sci index 381a158f..6a63e421 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 381a158f72c1efbb8e48229bc67c7a109dffe7c0 +Subproject commit 6a63e4212567ad0304a88094eeb2970317d0bfd8 diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 1761a550..f176f078 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -107,8 +107,8 @@ (if (some opts-map [:file :socket-repl :expression :main]) (assoc opts-map :command-line-args options) - (let [opt (str/triml opt) - c (.charAt opt 0)] + (let [trimmed-opt (str/triml opt) + c (.charAt trimmed-opt 0)] (case c (\( \{ \[ \* \@ \#) (assoc opts-map diff --git a/test/babashka/profile.clj b/test/babashka/profile.clj new file mode 100644 index 00000000..6f338e5f --- /dev/null +++ b/test/babashka/profile.clj @@ -0,0 +1,12 @@ +(ns babashka.profile + (:require [babashka.main :as main])) + +(comment) + +;; clojure -A:profile -e "(prn (loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val)))" + +#_(require '[clj-async-profiler.core :as prof]) + +(defn -main [& options] + #_(prof/profile (apply main/main options)) + (shutdown-agents))