Skip to content

Commit

Permalink
more logging, remove pprint for browser manifest
Browse files Browse the repository at this point in the history
saves about 500ms with many JS files
  • Loading branch information
thheller committed Apr 3, 2018
1 parent 76528f9 commit ec8edec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/main/shadow/build.clj
Expand Up @@ -14,7 +14,8 @@
[shadow.build.data :as data]
[clojure.tools.logging :as log]
[shadow.build.log :as build-log]
[clojure.set :as set]))
[clojure.set :as set]
[shadow.cljs.util :as util]))

(defn enhance-warnings
"adds source excerpts to warnings if line information is available"
Expand Down Expand Up @@ -100,6 +101,10 @@
[state]
(update state ::build-info merge (extract-build-info state)))

(defmethod build-log/event->str ::process-stage
[{:keys [target stage]}]
(format "build target: %s stage: %s" target stage))

(defn process-stage
[{::keys [config mode target-fn] :as state} stage optional?]
(let [before
Expand All @@ -108,7 +113,10 @@
(assoc-in [::build-info :timings stage :enter] (System/currentTimeMillis)))

after
(target-fn before)]
(util/with-logged-time [before {:type ::process-stage
:target (:target config)
:stage stage}]
(target-fn before))]
(if (and (not optional?) (identical? before after))
(throw (ex-info "process didn't do anything on non-optional stage"
{:stage stage :mode mode :config config}))
Expand Down
4 changes: 1 addition & 3 deletions src/main/shadow/build/targets/browser.clj
Expand Up @@ -7,7 +7,6 @@
[clojure.set :as set]
[clojure.java.shell :as sh]
[clojure.edn :as edn]
[clojure.pprint :refer (pprint)]
[shadow.cljs.repl :as repl]
[shadow.cljs.util :as util]
[shadow.build.api :as build-api]
Expand Down Expand Up @@ -317,8 +316,7 @@
manifest
(cond
(str/ends-with? manifest-name ".edn")
(with-out-str
(pprint data))
(core-ext/safe-pr-str data)

(str/ends-with? manifest-name ".json")
(with-out-str
Expand Down
26 changes: 25 additions & 1 deletion src/repl/shadow/cljs/resolve_test.clj
Expand Up @@ -215,13 +215,14 @@

(doseq [x resolved]
(prn x))
#_ (pprint (map second resolved))
#_(pprint (map second resolved))
#_(pprint str->sym)
#_(-> resolved-state :npm :index-ref deref :package-json-cache (pprint)))
(catch Exception e
(prn (ex-data e)))))



(deftest test-resolve-perf
(try

Expand All @@ -242,3 +243,26 @@
(catch Exception e
(prn (ex-data e))))
)

(defn resolve-entries [state entries]
(let [[resolved resolved-state]
(api/resolve-entries state entries)]

resolved-state
))


(comment
(def build-state
(-> (test-build)
(api/with-js-options
{:js-provider :shadow})))


(def resolve1 (time (resolve-entries build-state ["semantic-ui-react"])))
(def resolve2 (time (resolve-entries resolve1 ["semantic-ui-react"])))

(dotimes [x 100]
(time (resolve-entries resolve1 ["semantic-ui-react"])))

)

0 comments on commit ec8edec

Please sign in to comment.