Add CLI and Gradle support for profiling rules#9016
Add CLI and Gradle support for profiling rules#9016eygraber wants to merge 10 commits intodetekt:mainfrom
Conversation
|
|
If I backport this to v1 would you be able to make a new release for it? I think it would be helpful when it comes to deciding between updating from v1 to v2. |
| /* | ||
| This is not the best method to create root project aggregation tasks, but it is the only | ||
| way to do it without user intervention. If task abbreviations are used (e.g. `dPDSS` instead | ||
| of `detektProfileDebugSourceSet`) it will not work. | ||
|
|
||
| The "correct" method would be to require the user to register DetektProfilingAggregateTasks in the | ||
| root project manually. | ||
| */ |
There was a problem hiding this comment.
I don't have a good answer for what to do here. My gut feel is that this stays as a best effort, and if it doesn't work for a specific user for whatever reason they can register their own DetektProfilingAggregateTasks.
There was a problem hiding this comment.
Another option would be to provide a separate plugin that is applied to the root project, which provides an extension with a nice API that the user can use to register various different types of aggregating tasks.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9016 +/- ##
============================================
+ Coverage 85.13% 85.22% +0.09%
- Complexity 4380 4412 +32
============================================
Files 569 574 +5
Lines 12255 12365 +110
Branches 2642 2649 +7
============================================
+ Hits 10433 10538 +105
- Misses 676 680 +4
- Partials 1146 1147 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
TL;DR: Thanks for this PR, I'll review it soon. If you want an explanation about the late review continue reading. The only thing that scares me a bit is how this values should be read. The Analysis API is really lazy so the first rules will pay the time of that lazyness so they will "seem" slower than the last ones when that's maybe not the case. And this is not "theorical" in this comment we can see how after we remove the classpath-validation step the rule execution is slower. This is the reason I didn't review this PR yet, I don't know how to handle this. But, probably something is better than nothing so we could add this as a first step and then iterate. In a perfect world we would have perfetto traces of detekt execution. I think that we are far away from it as I couldn't find any easy way to create perfetto traces for JVM. (On Android is SO easy...) |
Fixes #6962
Adds support to the CLI and Gradle plugin for profiling rules (built on top of a new
RuleExecutionListener). Each project will generate a CSV containing the time it took to run each rule, and how many times they ran. There is also an aggregation task added to the root project that will write a combined CSV with the values from all of the subproject CSVs. It will also print the N slowest rules to the console.Sample aggregate:
The feature itself was ~1k additions; the rest is tests and documentation.