Offcourse there are many performance management tools but i am jotting here down Flog and Flay that i have worked on. To adhere to Rails Best Practices these two tools are simple enough to provide an insight for how to refactor the code for making testing effective.
1) Flog
It essentially scores an ABC Metric, giving a good understanding of the overall code complexity of any given file or method. Flog generates reports for each file in your application in order of its complexity and this scoring helps in refactoring, code cleanup, and making testing efforts highly effective. The ABC Metric is metric of software size and complexity like KLOC.
a) Assignment -- an explicit transfer of data into a variable, e.g. = *= /= %= += <<= >>= &= |= ^= >>>= ++ --
b) Branch -- an explicit forward program branch out of scope -- a function call, class method call, or new operator
c) Condition -- a logical/Boolean test, == != <= >= < > else case default try catch ? and unary conditionals.
Flog scores for an individual method can be interpreted into :-
Score of Means
0-10 Very good
11-20 Good enough
21-40 Might need refactoring
41-60 Possible to justify
61-100 Danger
100-200 Dirty
200 + Need to split into children
The 20 - 60 range is generally going good and exceeding it requires serious measure.
Instruction:
1) Install Flog; sudo gem install flog
2) To execute: goto project directory & type
find -name \*.rb | xargs flog > /log/flog.report
(report will created in log/flog.report file)
2) Flay
It analyzes ruby code for structural similarities. Differences in literal values, variable, class, method names, whitespace, programming style, braces, do/end, etc are all ignored and thus making it totally rad.The report Flay generates contains some code that could be a good candidate for refactoring.
The report may have the methods that are similar, but not identical. This is one of the clever features of Flay. It does n't just check for duplicated code, it also finds similarities in your code. The methods mentioned in report are similar enough that they could possibly be refactored into a new method, but there may be enough differences between them to conclude that they should be left separate.
Instruction:
1) Install Flog; sudo gem install flay
2) To execute: goto project directory & type
flay *.rb > /log/flay.report
(report will created in log/flay.report file)
Thanks & Regards
Kundan Kumar