Liking cljdoc? Tell your friends :D

taoensso.tufte

A simple, fast, monitoring profiler for Clojure/Script.

Core API:

These macros conditionally[1] activate thread-local or dynamic (multi-threaded) profiling for their body:

(profiled         [level          & body] [level          :when test & body])
(profiled-dynamic [level          & body] [level          :when test & body])
(profile          [level stats-id & body] [level stats-id :when test & body])
(profile-dynamic  [level stats-id & body] [level stats-id :when test & body])

profiled* ALWAYS returns [<result> ?<thread-local-stats>] vector. profile* ALWAYS returns <result>; and handles[2] ?<thread-local-stats>.

[1] Compile-time elision for: [level ns] Runtime filtering for: [level ns (test)] ; Note optional arbitrary test

[2] See set-handler! to un/register handler fn/s (e.g. for logging or further analysis).


This macro conditionally[3] records body execution times when profiling is active:

(p [form-id & body] [level form-id & body]) ; ALWAYS returns body's result

[3] Compile-time elision for: [level ns] Runtime filtering for: [profiling-active?]

Please see the API docs for more info.

How/where to use this library:

Tufte is highly optimized: even without elision, you can usually leave profiling code in production (e.g. for sampled profiling, or to detect unusual performance behaviour). Tufte's stats maps are well suited to programmatic inspection + analysis.

A simple, fast, monitoring profiler for Clojure/Script.

Core API:
=========
  These macros conditionally[1] activate thread-local or dynamic
  (multi-threaded) profiling for their body:

    (profiled         [level          & body] [level          :when test & body])
    (profiled-dynamic [level          & body] [level          :when test & body])
    (profile          [level stats-id & body] [level stats-id :when test & body])
    (profile-dynamic  [level stats-id & body] [level stats-id :when test & body])

  `profiled*` ALWAYS returns [<result> ?<thread-local-stats>] vector.
  `profile*`  ALWAYS returns  <result>; and handles[2] ?<thread-local-stats>.

  [1] Compile-time elision for: [level ns]
      Runtime filtering for:    [level ns (test)] ; Note optional arbitrary test

  [2] See `set-handler!` to un/register handler fn/s (e.g. for logging or
      further analysis).

  -------------------------------------------------------------------------

  This macro conditionally[3] records body execution times when profiling
  is active:

    (p [form-id & body] [level form-id & body]) ; ALWAYS returns body's result

  [3] Compile-time elision for: [level ns]
      Runtime filtering for:    [profiling-active?]

  Please see the API docs for more info.

How/where to use this library:
==============================
  Tufte is highly optimized: even without elision, you can usually leave
  profiling code in production (e.g. for sampled profiling, or to detect
  unusual performance behaviour). Tufte's stats maps are well suited to
  programmatic inspection + analysis.
raw docstring

*min-level*clj/s

e/o #{0 1 2 3 4 5 6}

e/o #{0 1 2 3 4 5 6}
raw docstring

*ns-filter*clj/s

(fn [?ns] -> truthy).

(fn [?ns] -> truthy).
raw docstring

-compile-ns-filterclj/s

Caching impl/comple-ns-filter.

Caching `impl/comple-ns-filter`.
raw docstring

-elide?clj

(-elide? level-form ns-str-form)

Returns true iff level or ns are compile-time filtered.

Returns true iff level or ns are compile-time filtered.
raw docstring

-fn-sigsclj/s

(-fn-sigs fn-name sigs)

-handle!clj/smacro

(-handle! level id stats)

accumulate-statsclj/s

(accumulate-stats stats-accumulator [profiled-result profiled-?stats])

Experimental, subject to change!

Experimental, subject to change!
raw docstring

chanceclj/s

(chance p)

Returns true with 0<p<1 probability.

Returns true with 0<`p`<1 probability.
raw docstring

compile-ns-filterclj/s

(compile-ns-filter ns-pattern)

Returns (fn [?ns]) -> truthy. Some example patterns: "foo.bar", "foo.bar.", #{"foo" "bar"}, {:whitelist ["foo.bar."] :blacklist ["baz.*"]}

Returns (fn [?ns]) -> truthy. Some example patterns:
"foo.bar", "foo.bar.*", #{"foo" "bar"},
{:whitelist ["foo.bar.*"] :blacklist ["baz.*"]}
raw docstring

defnpclj/smacro

(defnp name doc-string? attr-map? [params*] prepost-map? body)
(defnp name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?)

Like defn but wraps fn bodies with p macro.

Like `defn` but wraps fn bodies with `p` macro.
raw docstring

fnpclj/smacro

(fnp name? ([params*] prepost-map? body) +)
(fnp name? [params*] prepost-map? body)

Like fn but wraps fn bodies with p macro.

Like `fn` but wraps fn bodies with `p` macro.
raw docstring

format-statsclj/s

(format-stats stats)
(format-stats stats sort-field)

HandlerValcljs


invalid-form-level-msgclj/s


invalid-min-level-msgclj/s


may-profile?clj/s

(may-profile? level)
(may-profile? level ns)

Returns true iff level and ns are runtime unfiltered.

Returns true iff level and ns are runtime unfiltered.
raw docstring

merge-statsclj/s

(merge-stats s1 s2)

Merges stats maps from multiple runs or threads. Automatically identifies and merges concurrent time windows.

Merges stats maps from multiple runs or threads.
Automatically identifies and merges concurrent time windows.
raw docstring

pclj/smacro

(p form-id & body)
(p level form-id & body)

Profiling spy. When ns is unfiltered and profiling is active, records execution time of named body. Always returns body's result.

Profiling spy. When ns is unfiltered and profiling is active, records
execution time of named body. Always returns body's result.
raw docstring

profileclj/smacro

(profile level stats-id & body)
(profile level stats-id :when test & body)

When level+ns+test are unfiltered, executes named body with thread-local profiling active and dispatches stats to any registered handlers. Always returns body's result.

When level+ns+test are unfiltered, executes named body with thread-local
profiling active and dispatches stats to any registered handlers.
Always returns body's result.
raw docstring

profile-dynamicclj/smacro

(profile-dynamic level stats-id & body)
(profile-dynamic level stats-id :when test & body)

Like profile but executes body with dynamic (multi-threaded) profiling active. Always returns body's result.

Like `profile` but executes body with dynamic (multi-threaded) profiling
active. Always returns body's result.
raw docstring

profiledclj/smacro

(profiled level & body)
(profiled level :when test & body)

When level+ns+test are unfiltered, executes body with thread-local profiling active. Always returns [<body-result> ?<stats>].

When level+ns+test are unfiltered, executes body with thread-local
profiling active. Always returns [<body-result> ?<stats>].
raw docstring

profiled-dynamicclj/smacro

(profiled-dynamic level & body)
(profiled-dynamic level :when test & body)

Like profiled but executes body with dynamic (multi-threaded) profiling active. Always returns [<body-result> ?<stats>].

Like `profiled` but executes body with dynamic (multi-threaded) profiling
active. Always returns [<body-result> ?<stats>].
raw docstring

profiling?clj/s

(profiling?)

Returns e/o #{nil :thread-local :dynamic}.

Returns e/o #{nil :thread-local :dynamic}.
raw docstring

pspyclj/smacro

(pspy & specs)

p alias

`p` alias
raw docstring

set-basic-println-handler!clj/s

(set-basic-println-handler!)

set-handler!clj/s

(set-handler! handler-id ?handler-fn)
(set-handler! handler-id ?handler-fn ?ns-filter)

Use to un/register interest in stats output.

nil ?handler-fn => unregister id. nnil ?handler-fn => register id: (handler-fn {:level _ :ns-str _ :id _ :stats _ :stats-str _}) will be called for stats output produced by any profile or profile-dynamic calls.

Handler ideas: Save to a db, log, put! to an appropriate core.async channel, filter, aggregate, use for a realtime analytics dashboard, examine for outliers or unexpected output, ...

NB: handler errors will be silently swallowed. Please try/catch and appropriately deal with (e.g. log) possible errors within your handler fns.

Use to un/register interest in stats output.

nil  `?handler-fn` => unregister id.
nnil `?handler-fn` =>   register id:
  `(handler-fn {:level _ :ns-str _ :id _ :stats _ :stats-str _})`
  will be called for stats output produced by any `profile` or
 `profile-dynamic` calls.

Handler ideas:
  Save to a db, log, `put!` to an appropriate `core.async`
  channel, filter, aggregate, use for a realtime analytics dashboard,
  examine for outliers or unexpected output, ...

NB: handler errors will be silently swallowed. Please `try`/`catch`
and appropriately deal with (e.g. log) possible errors *within* your
handler fns.
raw docstring

set-min-level!clj/s

(set-min-level! level)

Sets root binding of minimum profiling level, e/o #{0 1 2 3 4 5 6}. 0 => Enable all profiling. 6 => Disable all profiling.

Sets root binding of minimum profiling level, e/o #{0 1 2 3 4 5 6}.
0 => Enable  all profiling.
6 => Disable all profiling.
raw docstring

set-ns-pattern!clj/s

(set-ns-pattern! ns-pattern)

Sets root binding of namespace filter. See compile-ns-filter docstring for details on ns-pattern arg.

Sets root binding of namespace filter.
See `compile-ns-filter` docstring for details on `ns-pattern` arg.
raw docstring

start-thread-local-profiling!clj/s

(start-thread-local-profiling!)

Warning: this is a low-level primitive. Prefer higher-level macros like profile when possible.

NB: must be accompanied by a call to stop-thread-local-profiling! (e.g. using try/finally).

Warning: this is a low-level primitive. Prefer higher-level macros
like `profile` when possible.

NB: must be accompanied by a call to `stop-thread-local-profiling!`
(e.g. using `try`/`finally`).
raw docstring

stats-accumulatorclj/s

(stats-accumulator)

Experimental, subject to change! Small util to help merge stats maps from multiple runs or threads. Returns a stateful fn with arities: ([stats-map]) ; Accumulates the given stats (you may call this from any thread) ([]) ; Deref: returns the merged value of all accumulated stats

Experimental, subject to change!
Small util to help merge stats maps from multiple runs or threads.
Returns a stateful fn with arities:
  ([stats-map]) ; Accumulates the given stats (you may call this from any thread)
  ([])          ; Deref: returns the merged value of all accumulated stats
raw docstring

stop-thread-local-profiling!clj/s

(stop-thread-local-profiling!)

Warning: this is a low-level primitive.

Warning: this is a low-level primitive.
raw docstring

valid-form-levelclj/s

(valid-form-level x)

valid-form-level?clj/s

(valid-form-level? x)

valid-min-levelclj/s

(valid-min-level x)

valid-min-level?clj/s

(valid-min-level? x)

with-min-levelclj/smacro

(with-min-level level & body)

Executes body with dynamic minimum profiling level, e/o #{0 1 2 3 4 5 6}. 0 => Enable all profiling. 6 => Disable all profiling.

Executes body with dynamic minimum profiling level, e/o #{0 1 2 3 4 5 6}.
0 => Enable  all profiling.
6 => Disable all profiling.
raw docstring

with-ns-patternclj/smacro

(with-ns-pattern ns-pattern & body)

Executes body with dynamic namespace filter. See compile-ns-filter docstring for details on ns-pattern arg.

Executes body with dynamic namespace filter.
See `compile-ns-filter` docstring for details on `ns-pattern` arg.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close