Fork me on GitHub
#component
<
2023-12-01
Noah Bogart19:12:58

does anyone have libraries or utilities to measure start and stop times of individual components? i'm researching why our test suite is slow and two parts stood out to me: roughly 0.5 seconds to in component/start and roughly 1 second in component/stop , which we're calling as :each fixtures in all our test files.

seancorfield20:12:26

We have "slow" start/`stop` times too but we did two things to improve test suite times: • We switched to :once fixtures • We added a per-suite fixture by tapping into the test runner itself and added start/`stop` there for some parts of the suite (`start` is idempotent, but the trick to prevent stop tearing things down was to track in the start function whether the system was already started and then have stop do nothing if start hadn't done anything -- allowing the system to be long-lived) The main thing for us, I think, was starting the various connection pools for the databases (we have four main SQL databases and we have a couple of extra readonly pools as well), so having all that happen only one per test suite made a big difference.

Noah Bogart20:12:02

that sounds really good. our test system is kind of a mess (we're calling migratus/migrate every start up, lol) but the biggest issue is starting and stopping everything every deftest. i'll see if i can implement something similar!

Noah Bogart20:12:08

do you have allowance to share any of that code?

seancorfield20:12:39

Unfortunately, it's pretty tied into our app-specific code.

seancorfield20:12:12

We're using Polylith, which has per-project fixtures in addition to the per-namespace/per-test which clojure.test provides.

Noah Bogart20:12:32

dang, that's cool tho

Noah Bogart20:12:35

good way to think about it