|
14 | 14 | `p`, `profiled`, `profile`, `add-handler!`, etc.
|
15 | 15 |
|
16 | 16 | (p [opts & body] [id & body]) ; e.g. `(p ::my-id (do-work))`
|
17 |
| - (profiled [opts & body]) ; e.g. `(profiled {:level 2} (my-fn))` |
18 |
| - (profile [opts & body]) ; e.g. `(profiled {:level 2} (my-fn))` |
| 17 | + (profiled [opts & body]) ; e.g. `(profiled {:level :info} (my-fn))` |
| 18 | + (profile [opts & body]) ; e.g. `(profiled {:level :info} (my-fn))` |
19 | 19 |
|
20 | 20 | (add-handler! [handler-id handler-fn dispatch-opts])
|
21 | 21 |
|
|
101 | 101 | (impl/defhelp help:signal-content :signal-content)
|
102 | 102 | (impl/defhelp help:environmental-config :environmental-config))
|
103 | 103 |
|
104 |
| -;;;; Vestigial |
105 |
| - |
106 |
| -(def ^:dynamic *min-level* "Vestigial, currently ignored." 2) |
107 |
| -(def ^:dynamic *ns-filter* "Vestigial, currently ignored." "*") |
108 |
| - |
109 | 104 | ;;;; Low-level primitives
|
110 | 105 |
|
111 | 106 | (defn profiling? "Returns e/o #{nil :thread :dynamic}."
|
|
228 | 223 | :arglists '([id & body] [{:keys [id level]} & body])}
|
229 | 224 | [s1 & body]
|
230 | 225 | (let [opts (if (map? s1) s1 {:id s1})
|
231 |
| - level-form (get opts :level 5) |
| 226 | + level-form (get opts :level :info) |
232 | 227 | id-form (get opts :id)
|
233 | 228 | location
|
234 | 229 | (enc/assoc-some nil
|
|
272 | 267 |
|
273 | 268 | [opts & body]
|
274 | 269 | (impl/valid-opts! &form &env 'tufte/profiled opts body)
|
275 |
| - (let [opts (merge {:level 5} opts) |
| 270 | + (let [opts (merge {:level :info} opts) |
276 | 271 | ns-form* (get opts :ns :auto)
|
277 | 272 | ns-form (auto-> ns-form* (str *ns*))
|
278 | 273 |
|
|
299 | 294 | (macroexpand '(profiled {:allow? false}))
|
300 | 295 |
|
301 | 296 | (profiled {} (p :p1 nil))
|
302 |
| - (profiled {} (p {:level 5 :id :p1} nil)) |
| 297 | + (profiled {} (p {:level :info :id :p1} nil)) |
303 | 298 | (profiled {} (p (let [x :foo/id] x) "body"))
|
304 |
| - (profiled {:level 2 :when (chance 0.5)} (p :p1 "body")) |
| 299 | + (profiled {:level :info :when (chance 0.5)} (p :p1 "body")) |
305 | 300 | (profiled {} (p :foo (p :bar nil))))
|
306 | 301 |
|
307 | 302 | #?(:clj
|
|
316 | 311 | (let [cljs? (boolean (:ns &env))
|
317 | 312 | clj? (not cljs?)
|
318 | 313 |
|
319 |
| - opts (merge {:level 5} opts) |
| 314 | + opts (merge {:level :info} opts) |
320 | 315 | ns-form* (get opts :ns :auto)
|
321 | 316 | ns-form (auto-> ns-form* (str *ns*))
|
322 | 317 |
|
|
801 | 796 | (p :10ms (Thread/sleep 10))
|
802 | 797 | "Result"))
|
803 | 798 |
|
804 |
| - (profile {:level 2 :id ::sleepy :data "foo"} (sleepy-threads)) |
805 |
| - (profile {:level 2 :id ::sleepy :dynamic? true} (sleepy-threads)) |
| 799 | + (profile {:level :info :id ::sleepy :data "foo"} (sleepy-threads)) |
| 800 | + (profile {:level :info :id ::sleepy :dynamic? true} (sleepy-threads)) |
806 | 801 | (p :hello "Hello, this is a result") ; Falls through (no pdata context)
|
807 | 802 |
|
808 | 803 | (defnp arithmetic []
|
|
819 | 814 | (profile {} (dotimes [n 1e5] (p :p1 nil)))
|
820 | 815 | (profile {} (dotimes [n 1e6] (p :p1 nil)))
|
821 | 816 | (profiled {} (dotimes [n 1e6] (p :p1 nil)))
|
822 |
| - (profiled {:level 2 :when (chance 0.5)} "body") |
| 817 | + (profiled {:level :info :when (chance 0.5)} "body") |
823 | 818 |
|
824 | 819 | @(second (profiled {:nmax 10000 :dynamic? true} (dotimes [n 200] (p :p1 nil))))
|
825 | 820 |
|
|
0 commit comments