******************************************************************************** * * * F I T D E C O R A T O R * * * ********************************************************************************Why do we need decorators for fit?
Consider you have a simple fit test as follows:
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
Now you want to measure how much time this test is taking to execute. But you don't want to or cannot modify the existing test fixture. Basically you want to decorate the existing fit tests with extra features. It would be cool if you could write a decorator around your fit test which starts a timer before the execution of the fit test starts, runs the fit test as usual and once the execution is completed it records the amount of time it took to run the fit fixture. An assertion on the execution time to make sure it executes within a max time is also quite handy to be aware of the application's performance over a period of time. Something like this:
1. Max Time Decoratorfit.decorator.performance.MaxTime | 100 actual 0.0 | milliseconds |
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
You could have other needs like, executing the same fit test multiple times or checking the standard deviation on the time it takes to execute the same test multiple times. All these seem like nice candidates for a decorator pattern. Hence this project. We have a few other interesting examples for you:
2. Max Time with Looping: You might want to loop 5 times and make sure each time it test does not take more than 100 millisecondsfit.decorator.Loop | 5 | times |
fit.decorator.performance.MaxTime | 100 actual 0.0 actual 0.0 actual 0.0 actual 15.0 actual 0.0 | milliseconds |
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
fit.decorator.performance.MaxTime | 25 actual 16.0 | milliseconds |
fit.decorator.Loop | 5 | times |
fit.decorator.performance.MaxTime | 20 actual 0.0 actual 0.0 actual 16.0 actual 0.0 actual 0.0 | milliseconds |
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
fit.decorator.performance.TimeRange | 0 actual 15.0 | milliseconds min and max | 30 actual 15.0 | milliseconds |
eg.Division | ||||
numerator | denominator | quotient() | ||
10 | 2 | 5 | ||
12.6 | 3 | 4.2 | ||
100 | 4 | 25 |
fit.decorator.performance.StandardDeviationOfElapsedTime | 0.1 actual 0.0 | with average | 1 actual 0.0 | millisecond when repeated | 5 | times |
eg.Division | ||||||
numerator | denominator | quotient() | ||||
10 | 2 | 5 | ||||
12.6 | 3 | 4.2 | ||||
100 | 4 | 25 |
fit.decorator.IncrementColumnsValue | numerator | of type | int | by | 5 |
eg.Division | |||||
numerator | denominator | quotient() | |||
10 | 2 | 5 | |||
10 | 3 | 5 | |||
10 | 4 | 5 |
fit.decorator.IncrementColumnsValue | numerator | of type | int | by | 5 |
eg.Division | |||||
numerator | denominator | quotient() | |||
10 | 2 | 5 | |||
15 | 3 | 5 | |||
20 | 4 | 5 |
fit.decorator.CopyAndAppendLastRow | 5 | number of times |
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
fit.decorator.CopyAndAppendLastRow | 5 | number of times |
eg.Division | ||
numerator | denominator | quotient() |
10 | 2 | 5 |
12.6 | 3 | 4.2 |
100 | 4 | 25 |
100 | 4 | 25 |
100 | 4 | 25 |
100 | 4 | 25 |
100 | 4 | 25 |
100 | 4 | 25 |
fit.decorator.CopyAndAppendLastRow | 5 | times | |||
fit.decorator.IncrementColumnsValue | numerator | of type | int | by | 5 |
fit.decorator.IncrementColumnsValue | denominator | of type | int | by | 1 |
eg.Division | |||||
numerator | denominator | quotient() | |||
5 | 1 | 5 |
fit.decorator.CopyAndAppendLastRow | 100 | times | |||
fit.decorator.IncrementColumnsValue | numerator | of type | int | by | 5 |
fit.decorator.IncrementColumnsValue | denominator | of type | int | by | 1 |
eg.Division | |||||
numerator | denominator | quotient() | |||
5 | 1 | 5 | |||
10 | 2 | 5 | |||
15 | 3 | 5 | |||
20 | 4 | 5 | |||
25 | 5 | 5 | |||
30 | 6 | 5 |