~severeoverfl0w/slow-namespace-clj

Find slow namespaces to require in Clojure projects
~severeoverfl0w/public-todo

New ticket tracker added

4 months ago
~severeoverfl0w/public-inbox

New mailing list added

4 months ago

#slow-namespace-clj

Find which namespaces are slowest in your project.

#Usage

Add an alias to ~/.clojure/deps.edn

:user/slow-namespace-clj
{:extra-deps
 {io.dominic/slow-namespace-clj
  {:git/url "https://git.sr.ht/~severeoverfl0w/slow-namespace-clj"
   :sha "9a804bd37c662629c3ecda18375c59fd8d9f0928"}}
 :main-opts ["-m" "io.dominic.slow-namespace-clj.core"]}

Then you can scan for just dependencies of your project, by specifying the directories from your project. By default, namespaces faster than 0.1msecs are hidden, which can be changed with the -t flag.

# Main project
$ clojure -A:user/slow-namespace-clj src
# For development
$ clojure -A:dev:user/slow-namespace-clj src dev test
# Change threshold
$ clojure -A:user/slow-namespace-clj -t 100 src
# Dirs starting with - (very rare)
$ clojure -A:user/slow-namespace-clj -t 100 -- -src
# Everything on classpath (includes unused namespaces)
$ clojure -A:user/slow-namespace-clj
# Test speed of a library & it's deps (run without a deps.edn)
clj -Sdeps '{:deps {metosin/reitit {:mvn/version "0.5.5"}}}' -A:user/slow-namespace-clj

#Output

Namespaces are sorted from fastest to slowest.

A section called "groups" prints out the namespace prefixes and their speeds, to help identify slow libraries.

Sample from a web project:

clojure.set : 0.369902 msecs
clojure.java.io : 0.450503 msecs
clojure.walk : 0.561018 msecs
clojure.edn : 0.623314 msecs
clojure.reflect : 0.634485 msecs
clojure.spec.gen.alpha : 0.636385 msecs
clojure.core : 0.68387 msecs
clojure.spec.alpha : 0.705296 msecs
clojure.string : 0.786248 msecs
clojure.stacktrace : 4.093704 msecs
yada.status : 5.92224 msecs
clojure.tools.analyzer.passes.cleanup : 6.310698 msecs
ring.swagger.swagger2-schema : 6.767271 msecs
foo.bar.core : 6.852265 msecs
yada.aleph : 6.855906 msecs
yada.async : 7.546163 msecs
yada.resources.string-resource : 7.559982 msecs
yada.json-html : 7.630742 msecs
yada.wrappers : 7.739301 msecs
yada.resources.exception-resource : 7.777184 msecs
manifold.debug : 8.154497 msecs
clojure.xml : 8.344612 msecs
ring.swagger.extension : 8.523722 msecs
yada.resources.sse : 8.759905 msecs
linked.core : 8.766016 msecs
clojure.tools.analyzer.passes.jvm.fix-case-test : 8.850953 msecs
clojure.tools.analyzer.passes.add-binding-atom : 8.915659 msecs
clojure.tools.analyzer.passes.jvm.constant-lifter : 8.961169 msecs
manifold.stream.async : 9.191161 msecs
clojure.core.async.impl.concurrent : 9.202487 msecs
ring.util.parsing : 9.35265 msecs
yada.resources.url-resource : 9.448235 msecs
yada.resources.atom-resource : 9.618961 msecs
clojure.core.async.impl.mutex : 9.673702 msecs
clojure.tools.analyzer.passes.warn-earmuff : 9.828598 msecs
hiccup.core : 9.834471 msecs
ring.middleware.head : 9.9499 msecs
schema-tools.util : 10.45378 msecs
bidi.schema : 10.651775 msecs
yada.etag : 11.000782 msecs
clojure.tools.analyzer.passes.source-info : 11.3232 msecs
yada.test : 11.667529 msecs
ring.util.io : 12.006575 msecs
ring.swagger.json : 12.1699 msecs
ring.util.time : 12.243654 msecs
clojure.core.async.impl.exec.threadpool : 12.317577 msecs
potemkin.walk : 12.375989 msecs
yada.resources.classpath-resource : 12.449486 msecs
yada.suffixes : 12.851352 msecs
yada.resources.resources-resource : 12.8597 msecs
ring.swagger.schema : 12.945094 msecs
yada.authentication : 12.999405 msecs
ring.util.mime-type : 13.117303 msecs
clojure.core.async.impl.dispatch : 13.154105 msecs
yada.redirect : 14.022399 msecs
yada.bmh : 14.528651 msecs
yada.resources.collection-resource : 14.581493 msecs
clojure.tools.analyzer.passes.jvm.classify-invoke : 14.983636 msecs
ring.middleware.resource : 15.090337 msecs
aleph.http.encoding : 15.439809 msecs
clojure.tools.analyzer.env : 15.798823 msecs
clojure.tools.analyzer.passes.elide-meta : 15.840318 msecs
potemkin.macros : 16.162696 msecs
clojure.tools.analyzer.passes.constant-lifter : 16.536388 msecs
linked.set : 17.001384 msecs
hiccup.def : 17.360588 msecs
clojure.tools.analyzer.passes.trim : 18.29623 msecs
org.tobereplaced.lettercase.internal : 18.329761 msecs
yada.resources.webjar-resource : 18.516809 msecs
yada.json : 18.795012 msecs
ring.middleware.not-modified : 18.873348 msecs
ring.swagger.common : 19.63289 msecs
clojure.core.async.impl.timers : 19.634114 msecs
yada.coerce : 20.001623 msecs
aleph.flow : 20.158335 msecs
ring.middleware.params : 20.446078 msecs
aleph.http.multipart : 20.449022 msecs
yada.transit : 21.038204 msecs
yada.authorization : 21.209176 msecs
clojure.tools.reader.impl.utils : 21.542272 msecs
clj-tuple : 21.716817 msecs
org.tobereplaced.lettercase.protocols : 21.759084 msecs
clojure.tools.analyzer.passes.jvm.warn-on-reflection : 21.795536 msecs
plumbing.fnk.pfnk : 22.639997 msecs
clojure.tools.analyzer.passes.jvm.validate-recur : 23.2047 msecs
clojure.tools.analyzer.passes.uniquify : 24.241422 msecs
clojure.tools.analyzer.passes.jvm.annotate-host-info : 25.022936 msecs
hiccup.page : 25.552275 msecs
yada.bidi : 26.101114 msecs
clojure.tools.analyzer.passes.jvm.annotate-tag : 26.732647 msecs
clojure.tools.reader.impl.inspect : 26.739135 msecs
manifold.stream.random-access : 27.594465 msecs
clojure.core.async.impl.buffers : 28.239629 msecs
schema.spec.leaf : 28.729307 msecs
clojure.tools.reader.impl.commons : 29.708202 msecs
ring.swagger.core : 30.375665 msecs
manifold.stream.iterator : 30.452256 msecs
schema-tools.coerce : 30.58502 msecs
clojure.tools.analyzer.passes.jvm.analyze-host-expr : 31.370077 msecs
schema-tools.impl : 31.426849 msecs
clojure.tools.analyzer.passes.jvm.annotate-loops : 32.11139 msecs
yada.context : 32.601407 msecs
schema-tools.walk : 32.943533 msecs
byte-streams.char-sequence : 33.626053 msecs
manifold.stream.seq : 34.415302 msecs
yada.yada : 35.337964 msecs
riddley.compiler : 35.372924 msecs
clojure.tools.analyzer.ast : 35.438866 msecs
yada.swagger-parameters : 36.536128 msecs
byte-streams.protocols : 37.320564 msecs
ring.util.request : 38.397955 msecs
cheshire.factory : 38.54453 msecs
cheshire.core : 39.707937 msecs
json-html.core : 40.965332 msecs
ring.middleware.content-type : 42.536415 msecs
schema.spec.core : 43.522049 msecs
plumbing.fnk.impl : 44.145473 msecs
clojure.tools.analyzer.passes : 44.548728 msecs
clojure.data.codec.base64 : 45.640597 msecs
hiccup.util : 46.078179 msecs
yada.interceptors : 46.9688 msecs
cheshire.parse : 47.16456 msecs
cognitect.transit : 48.119255 msecs
byte-streams.utils : 49.031945 msecs
yada.cookies : 49.04663 msecs
schema.spec.variant : 49.58129 msecs
linked.map : 49.650277 msecs
manifold.stream.queue : 49.847324 msecs
potemkin.namespaces : 50.564084 msecs
potemkin.utils : 50.588819 msecs
manifold.utils : 51.750838 msecs
clojure.core.async.impl.channels : 52.084256 msecs
schema-tools.core : 52.23862 msecs
aleph.http : 52.398178 msecs
yada.request-body : 53.276014 msecs
ring.swagger.coerce : 53.32566 msecs
yada.security : 54.48287 msecs
clojure.tools.analyzer.passes.jvm.validate-loop-locals : 55.03787 msecs
schema.spec.collection : 55.055163 msecs
clojure.tools.reader.default-data-readers : 55.18074 msecs
clojure.tools.reader.impl.errors : 55.697967 msecs
clojure.tools.analyzer.passes.jvm.validate : 56.323757 msecs
clojure.data.priority-map : 56.699618 msecs
yada.parameters : 56.873009 msecs
ring.swagger.swagger2 : 60.298902 msecs
aleph.http.client : 60.463407 msecs
yada.media-type : 61.138382 msecs
ring.util.response : 61.327868 msecs
ring.util.codec : 63.340254 msecs
potemkin.types : 63.563608 msecs
yada.resource : 63.901119 msecs
schema.utils : 64.187741 msecs
clojure.core.memoize : 65.130222 msecs
riddley.walk : 65.985093 msecs
schema.coerce : 66.083766 msecs
yada.syntax : 66.404442 msecs
manifold.executor : 67.14869 msecs
clojure.tools.analyzer.utils : 67.150392 msecs
potemkin.collections : 67.19503 msecs
org.tobereplaced.lettercase : 69.344413 msecs
clojure.tools.analyzer.passes.jvm.infer-tag : 69.894565 msecs
clojure.tools.analyzer.passes.jvm.box : 71.172093 msecs
yada.util : 71.468236 msecs
clojure.core.async.impl.protocols : 72.542404 msecs
clojure.tools.logging.impl : 72.548467 msecs
manifold.stream.core : 73.609435 msecs
potemkin : 73.850442 msecs
manifold.stream.graph : 74.297927 msecs
hiccup.compiler : 75.724442 msecs
clj-time.coerce : 76.691133 msecs
yada.swagger : 78.119839 msecs
yada.handler : 80.470969 msecs
clojure.tools.analyzer.passes.jvm.emit-form : 81.178474 msecs
clojure.tools.analyzer.jvm.utils : 81.332611 msecs
ring.swagger.json-schema : 83.641909 msecs
bidi.vhosts : 83.834591 msecs
manifold.time : 83.965144 msecs
plumbing.core : 86.208754 msecs
yada.representation : 86.346319 msecs
weavejester.dependency : 86.918912 msecs
manifold.stream.default : 88.792816 msecs
aleph.http.server : 89.087297 msecs
clojure.pprint : 93.88228 msecs
clojure.tools.analyzer.passes.emit-form : 94.870252 msecs
cheshire.generate-seq : 98.144685 msecs
bidi.ring : 99.234962 msecs
yada.resources.file-resource : 99.816944 msecs
plumbing.fnk.schema : 101.606847 msecs
clojure.tools.analyzer : 110.043114 msecs
clojure.tools.logging : 111.315329 msecs
clojure.tools.analyzer.jvm : 113.553489 msecs
byte-streams.pushback-stream : 117.197777 msecs
cheshire.generate : 117.932396 msecs
yada.body : 123.983604 msecs
schema.macros : 126.576758 msecs
clj-time.format : 132.756437 msecs
byte-streams.graph : 145.435608 msecs
yada.multipart : 155.075817 msecs
clojure.core.cache : 158.901297 msecs
yada.methods : 172.468566 msecs
yada.schema : 175.363016 msecs
clojure.tools.reader.reader-types : 186.007442 msecs
clojure.tools.reader : 189.170432 msecs
integrant.core : 190.760936 msecs
primitive-math : 194.218309 msecs
aleph.http.client-middleware : 215.272995 msecs
bidi.bidi : 236.11306 msecs
byte-streams : 277.458812 msecs
aleph.http.core : 283.4083 msecs
manifold.deferred : 330.321318 msecs
clj-time.core : 391.552941 msecs
yada.charset : 398.45088 msecs
aleph.netty : 488.51651 msecs
clojure.core.async.impl.ioc-macros : 497.0484 msecs
schema.core : 678.299567 msecs
clojure.core.async : 1067.142285 msecs
manifold.stream : 5152.286038 msecs
-- [Groups] --
aleph : 1245.193853 msecs
aleph.http : 684.12083 msecs
bidi : 429.834388 msecs
byte-streams : 382.61194700000004 msecs
cheshire : 341.494108 msecs
clj-time : 601.000511 msecs
clojure : 4167.760887 msecs
clojure.core : 2005.0704779999999 msecs
clojure.core.async.impl : 713.896674 msecs
clojure.core.async.impl.exec : 12.317577 msecs
clojure.data : 102.340215 msecs
clojure.data.codec : 45.640597 msecs
clojure.java : 0.450503 msecs
clojure.spec : 1.341681 msecs
clojure.spec.gen : 0.636385 msecs
clojure.tools : 1948.5785770000002 msecs
clojure.tools.analyzer : 1090.6254769999998 msecs
clojure.tools.analyzer.jvm : 81.332611 msecs
clojure.tools.analyzer.passes : 732.8025680000003 msecs
clojure.tools.analyzer.passes.jvm : 526.639803 msecs
clojure.tools.logging : 72.548467 msecs
clojure.tools.reader : 374.875758 msecs
clojure.tools.reader.impl : 133.687576 msecs
cognitect : 48.119255 msecs
foo.bar : 6.852265 msecs
hiccup : 174.549955 msecs
integrant : 190.760936 msecs
json-html : 40.965332 msecs
linked : 75.417677 msecs
manifold : 6081.827211 msecs
manifold.stream : 388.20068599999996 msecs
org.tobereplaced : 109.43325800000001 msecs
org.tobereplaced.lettercase : 40.088845000000006 msecs
plumbing : 254.601071 msecs
plumbing.fnk : 168.392317 msecs
potemkin : 260.45022600000004 msecs
riddley : 101.358017 msecs
ring : 604.36335 msecs
ring.middleware : 106.89607799999999 msecs
ring.swagger : 287.681013 msecs
ring.util : 209.786259 msecs
schema : 1112.035641 msecs
schema-tools : 157.647802 msecs
schema.spec : 176.887809 msecs
weavejester : 86.918912 msecs
yada : 2319.6123089999996 msecs
yada.resources : 201.388699 msecs