wakatime / jetbrains-wakatime

IntelliJ IDEA, PyCharm, RubyMine, PhpStorm, AppCode, AndroidStudio, Goland, Rider, & WebStorm plugin for quantifying your coding.
https://wakatime.com/intellij-idea
BSD 3-Clause "New" or "Revised" License
1.12k stars 163 forks source link

Tracking Android build times #206

Closed Sternbach-Software closed 2 years ago

Sternbach-Software commented 2 years ago

I am having a meeting with my boss about my efficiency, and I want to explain to him that in 300 hours of development, I have probably spent in total 100 hours waiting for Android studio to build, because I don't have a nice computer, and that he should buy my a nice one. I estimated that number assuming I build 15 times every hour and that each build takes 30 seconds, but some hours I don't build at all and some builds take 7 minutes. So, I wish WakaTime would track exactly how long it took me to build the app over time.

I don't know how to build Intellij plugins nor how to set up the environment, so I can't create a PR myself, but I found the relevant files in the Intellij sdk:  GradleBuildState.java and GradleBuildListener.java. In the first file/class (GradleBuildState.java), there is a method named "subscribe" which takes the second file/class (GradleBuildListener.java) as a parameter. The second class is an interface with methods named buildExecutorCreated(), buildstarted () and buildFinished(). I assume the first one is called right when I click the build button, and is responsible for creating the Gradle daemon, and calls buildStarted() once the daemon is ready. I want to know how long it took from creating the daemon to finishing, because sometimes creating the daemon takes 20 second for me. All you would have to do is call System.nanoTime() in buildExecutorCreated() and in buildFinished() and the total time it took it, which is just the second call to System.nanoTime() minus the first call to System.nanoTime().

Please let me know what you think, as I would very possibly be willing to pay for premium if WakaTime had this simple feature to implement. Other than this, keep up the great work! Everything else is amazing!

This may also be helpful (e.g. may be necessary to create the plugin/listen to system build events, or may be helpful for tracking individual build tasks (there are a handful that go into every build and each has their own reason to blame if they are very long)): GradleBuildInvoker.java . Particularly of note are lines 405 through 539. 

alanhamlett commented 2 years ago

Duplicate of #116 and fixed in release v14.0.0.

Sternbach-Software commented 2 years ago

@alanhamlett Where do you view it on the dashboard?

alanhamlett commented 2 years ago

We had to rollback the release because it depends on Java and broke the plugin for other jetbrains IDEs, like PyCharm. We'll add a conditional dependency to only enable tracking build times in supported IDEs, then do another release.

https://github.com/wakatime/jetbrains-wakatime/issues/235