A Clojure library for profiling.
(require '[cider.inlined-deps.profile.v0v5v2.profile.core :refer :all])
(defn my-add [a b] (+ a b))
(defn my-mult [a b] (* a b))
(profile-vars my-add my-mult)
(profile {}
(my-add (my-mult (rand-int 100000) (rand-int 1000000))
(my-mult (rand-int 100000) (rand-int 1000000))))
profile
prints output to *err*
using pprint/print-table
; it
looks like this:
| :name | :n | :sum | :q1 | :med | :q3 | :sd | :mad |
|----------------+----+------+-----+------+-----+-----+------|
| #'user/my-add | 1 | 2µs | 2µs | 2µs | 2µs | 0µs | 0µs |
| #'user/my-mult | 2 | 11µs | 3µs | 8µs | 3µs | 3µs | 5µs |
A Clojure library for profiling. ## Example ```clojure (require '[cider.inlined-deps.profile.v0v5v2.profile.core :refer :all]) (defn my-add [a b] (+ a b)) (defn my-mult [a b] (* a b)) (profile-vars my-add my-mult) (profile {} (my-add (my-mult (rand-int 100000) (rand-int 1000000)) (my-mult (rand-int 100000) (rand-int 1000000)))) ``` `profile` prints output to `*err*` using `pprint/print-table`; it looks like this: ``` | :name | :n | :sum | :q1 | :med | :q3 | :sd | :mad | |----------------+----+------+-----+------+-----+-----+------| | #'user/my-add | 1 | 2µs | 2µs | 2µs | 2µs | 0µs | 0µs | | #'user/my-mult | 2 | 11µs | 3µs | 8µs | 3µs | 3µs | 5µs | ```
(max-sample-count)
Return maximum sample count of current profile session.
Return maximum sample count of current profile session.
(print-entry-summary name)
(print-entry-summary session name)
Prints a table of profiling statistics to *err*
for var with
name
if present. Returns nul.
Prints a table of profiling statistics to `*err*` for var with `name` if present. Returns nul.
(print-summary)
(print-summary session)
Prints to err statistics for profiled names. Returns nil.
Prints to *err* statistics for profiled names. Returns nil.
(profile options & body)
Execute body in a new profile session using options
and print
summary of collected profile data to *err*
using print-summary
.
Execute body in a new profile session using `options` and print summary of collected profile data to `*err*` using `print-summary`.
(profile-ns ns)
(profile-ns ns include-private?)
Equivalent to evaluating profile-var*
on each function-containing
var is ns
. If include-private?
is present and true, profile
functions associated with private vars in addition to public vars,
otherwise profile only public functions. Returns true value.
Equivalent to evaluating `profile-var*` on each function-containing var is `ns`. If `include-private?` is present and true, profile functions associated with private vars in addition to public vars, otherwise profile only public functions. Returns true value.
(profile-session)
(profile-session max-sample-count)
Inititalize profile session with optional maximum sample count. Default maximum sample count is 10,000.
Inititalize profile session with optional maximum sample count. Default maximum sample count is 10,000.
(profile-var var)
If var
is not already profiled, wraps the associated value with a
function that accrues time to the current profile session.
If `var` is not already profiled, wraps the associated value with a function that accrues time to the current profile session.
(profile-var* var)
Given a var value, profile it if it is not already profiled.
Given a var value, profile it if it is not already profiled.
(profile-vars & vars)
Equivalent to evaluating profile-var
on each element of vars
.
Equivalent to evaluating `profile-var` on each element of `vars`.
(profiled? f)
Reurns a true value if f
is currently profiled.
Reurns a true value if `f` is currently profiled.
(set-max-sample-count n)
Set maximum sample count of current profile session. Maximum sample count refers to the the maximum number of samples any individual name may be associated with. Value is applied when time is accured; this call will not truncate any profile data.
Set maximum sample count of current profile session. Maximum sample count refers to the the maximum number of samples any individual name may be associated with. Value is applied when time is accured; this call will not truncate any profile data.
(summary)
(summary session)
Returns a map containing two keys, :stats
and :agg-stats
. The
former containts a sequence of maps containing statistics describing
the profile data for each profiled name. :agg-stats
contains a map
of statistics relevant to the aggregate of all profiles names.
Returns a map containing two keys, `:stats` and `:agg-stats`. The former containts a sequence of maps containing statistics describing the profile data for each profiled name. `:agg-stats` contains a map of statistics relevant to the aggregate of all profiles names.
(toggle-profile-ns ns)
(toggle-profile-ns ns include-private?)
If any vars in ns
are profiled, unprofile all vars in ns
,
regardless whether public or private. If no vars in ns
are
profiled, profiles each public (and private, if include-private?
is present and true) function-containing var. Returns true value if
namespace is profiled.
If any vars in `ns` are profiled, unprofile all vars in `ns`, regardless whether public or private. If no vars in `ns` are profiled, profiles each public (and private, if `include-private?` is present and true) function-containing var. Returns true value if namespace is profiled.
(toggle-profile-var var)
Profiles or unprofiles var
depending on its current
state. Returns a truthy value if var
is profiled subsequent to
evaluation of this macro.
Profiles or unprofiles `var` depending on its current state. Returns a truthy value if `var` is profiled subsequent to evaluation of this macro.
(toggle-profile-var* v)
For use by cider-nrepl.
For use by cider-nrepl.
(unprofile-ns ns)
Equivalent to evaluating unprofile-var*
on each
function-containing var in ns
, whether public or private. Returns
not-true value.
Equivalent to evaluating `unprofile-var*` on each function-containing var in `ns`, whether public or private. Returns not-true value.
(unprofile-var var)
If var
is profiled, replaces binding with original function.
If `var` is profiled, replaces binding with original function.
(unprofile-var* var)
Given a var value, unprofile it if it is profiled.
Given a var value, unprofile it if it is profiled.
(unprofile-vars & vars)
Equivalent to evaluating unprofile-var
on each element of
vars
.
Equivalent to evaluating `unprofile-var` on each element of `vars`.
(with-session options & body)
Evaluate body
in context of a new profile sassion initializaed
with options
, a map that may contain a :max-sample-count
.
Evaluate `body` in context of a new profile sassion initializaed with `options`, a map that may contain a `:max-sample-count`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close