Squish/Using a Decorator to Profile Tests

From Qt Wiki
< Squish
Revision as of 15:00, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Use a decorator to profile tests

If your Squish tests are very intensive, or you have hundreds of them, you can run them trough a profiler from time to time. This will enable you to see where you’re spending most of your time and will help optimize your efforts.

In order to do this you will need to run your main function through the python profiling package cProfile. For example:

Depending on your particular configuration, the previous code might lead you to run the test twice. To avoid the repetition, wrap your main function with a decorator instead:

This technique also has the advantage of saving the code to profile in one single place. Also, you could turn it off or depending on an environment variable, you could report it in any way your particular setup requires.

Categories: