Is there a way to instrument the code and find out how much time each namespace takes or the only way forward is to use fixtures?
What is a good approach for solving such a problem?
Is there a way to instrument the code and find out how much time each namespace takes or the only way forward is to use fixtures?
What is a good approach for solving such a problem?
You can use eftest's :test-warn-time
to measure timing of tests per NS.
Once added, you'll see colored (not shown) output like this to indicate a slow test:
LONG TEST in foo-api.handlers.foo-test during :clojure.test/once-fixtures
Test took 12.300 seconds seconds to run
Your suggestion of using
run-tests
over a list of namespaces will work.Here is a function I wrote to loop ever namespaces in the repl, reload them all, then run tests for each ns. You could modify the code for your purpose. You would have to add code to capture the starting/ending time and print the elapsed time for each ns.
As the docstring says, this code assumes the namespaces are set up to look like:
so just strip out or modify the part with
(symbol (str "tst." curr-ns))
as required for your setup. You'll probably want to useall-ns
to get a listing of all namespaces, then either remove or ignore the non-testing namespaces. Good luck!