Suppose I have some code and it is important for me that the computational complexity observe some (algebraic) upper bound.
For instance, I might have an algorithm that when properly implemented runs in n^2, but if a bug is introduced runs in n^3. The test would check if the method is in fact running in n^2, and if not, fail it.
My question is, is it possible to accomplish this with MSTest?
I can see that after introducing a bunch of mathematical code, it would in principle be possible to fit given equations to empirical measurements and/or attempt to find the limit.
Alternatively, I imagine it might be possible to produce graphs, together with a best fit, and then ask the human for input on whether the test passes or not.
But are any of these actually realistic? Has anything similar ever been done?