Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a unit test that fails if compile time is above an acceptable level?

Sometimes code finds its way on to my teams dev branch that compiles very slowly. When this gets to the point where it's several minutes long we've no choice but to drop our tasks and search for what caused this else we'd lose a lot of time until we resolve it.

For our apps performance we have unit tests to stop our users experiencing slow times, I'm wondering if it's possible to device a test where slow compile times will cause our tests to fail so the changes that cause slow compiles times can be identified and removed immediately before they waste the entire teams time.

like image 643
Declan McKenna Avatar asked Nov 08 '22 18:11

Declan McKenna


1 Answers

You can add in your project's Build Settings -> Other Swift Flags the following flag: -Xfrontend -warn-long-function-bodies=<time> where in <time> you specify the amount of ms. You'll then be able to see warnings for any function that takes more time and fix them.

It's not gonna fail your tests but the whole team will be aware when they code something that takes too long to compile.

like image 150
PaschalisT Avatar answered Nov 15 '22 11:11

PaschalisT