asarkar / build-time-tracker Goto Github PK
View Code? Open in Web Editor NEWGradle plugin that prints the time taken by the tasks in a build
License: Apache License 2.0
Gradle plugin that prints the time taken by the tasks in a build
License: Apache License 2.0
Thank you for creating and maintaining this plugin.
It will be great if this can also keep track of how much time my machine spend building Android project by day, month and total.
Intellij gradle build shows ?
chars instead of bars.
:backend:commons:compileJava | 2S | 12% | ??
:backend:server:flywayClean | 4S | 24% | ????
:backend:server:flywayMigrate | 5S | 29% | ?????
:backend:server:compileJava | 1S | 6% | ?
:web:npmInstall | 1S | 6% | ?
Still informative, but looks bad.
Hi.
It looks like this plugin measures times between moments of time when task executions end. Not real time it takes to run a task. There is no difference if all tasks are executed one after another, but there is difference if tasks are executed in parallel.
For example, let's say we have tasks A and B. They are executed in parallel. Task A takes 9 seconds to finish, task B takes 10 seconds to finish. Total build time will be 10S for the whole build. Then this plugin will show.
A | 9S |
B | 1S |
Expected.
A | 9S |
B | 10S |
This issue makes build time measurements for individual tasks almost unusable in heavily modularized projects where lot of tasks are executed in parallel.
Not everyone may like bars.
Read first
Is your feature request related to a problem? Please describe
Description of what the problem is.
Hey, i want to have this feature disabled as default, and only show in CI/if user adds a parameter.
I haven't seen this option.
i think will be helpful.
Describe the solution you'd like
Description of what you want to happen.
add configuration for enable (true/false).
Describe alternatives you've considered
Description of any alternative solutions or features you've considered.
Environment
Additional context
Add any other context or screenshots about the feature request here.
Hey there! I was searching to build something similar until I came across your project. The main reason I'd looking to build would be to allow tracking the build time from from the developers machine. So let's say you have multiple squads working on the same project; each squad with multiple developers; so build time may becomes critical at some point.
I was thinking if it would make sense to upload those generated CSV files to some sort of remote storage like S3 (extensible to other providers). Plus adding a few extra properties in the CSV in order to be possible to know the machine configuration or maybe some way that consumers of the plugin can dynamically add columns they would like to have on top of the base columns.
Would you be considering such a thing and willing to take PRs towards that ?
Instead of sorting like this
:task1 | 27S | 30% | ███████████████████████████
:task2 | 17S | 19% | █████████████████
:task3 | 13S | 14% | █████████████
:task4 | 12S | 13% | ████████████
please let it be sorted like this by default.
:task4 | 12S | 13% | ████████████
:task3 | 13S | 14% | █████████████
:task2 | 17S | 19% | █████████████████
:task1 | 27S | 30% | ███████████████████████████
Or may be let it be an option.
The reason is that the tasks with the longest build times are the most interesting for us. By seeing which tasks run the longest we can detect potential build time issues. Or we can get insights about what should we focus on when optimizing build times.
Right now build times for the tasks with the longest build times are printed on the top of the output. Then there is a long tail of tasks with short build times. So in order for us to look at the most interesting tasks we need to scroll script output up. Which is very inconvenient and we may lose some insights because we won't do that scrolling after each build.
The output task durations are in seconds, which isn't very convenient. If a task runs for 3 minutes, it'll show up as 180.000s
, instead of the more human-friendly 3M
. Same argument applies to the minTaskDuration
configuration option. Both should be standardized.
This will be a breaking change.
Hi there! Thanks for supporting this library. I've been using the original version from passy as I need to document how bad our build times are and demonstrate with data, how much of an improvement on average each effort to reduce them achieves.
The original library supports writing to .csv files which I've been using, do you plan to provide support for anything similar? I don't see any documentation so I'm not sure it's supported here.
Describe the bug
Build times are not sorted if build configuration is restored from Gradle configuration cache.
When configuration phase is properly executed (configuration is not restored from the cache) then everything is sorted as expected.
To Reproduce
Use sortBy = com.asarkar.gradle.buildtimetracker.Sort.ASC
Gradle has configuration cache enabled.
Make sure build configuration is restored from the Gradle configuration cache. By executing the build second time without changing gradle files for example.
Expected behavior
Build times are sorted.
Environment
:service-client:compileKotlin | 1.432s | 8% | █
webapp:test | 13.882s | 76% | ██████████████
Fix misaligned durations.
Hey, I ran this plugin in our project and the total sum of the percentages in the time is not 100%, in my case it was 206%.
Is it expected ?
org.gradle.internal.event.ListenerNotificationException: Failed to notify build listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:86)
...
Caused by: java.lang.NoClassDefFoundError: kotlin/time/TimeSource$Monotonic
Looks like this plugin requires Java 11 or later,
but why?
can you provide Java8 Supporting, so we can use this plugin in our Java8 environment
Thanks~~~
When used in a Java project, this class is not available.
Clarify in the docs that it's sufficient to apply the plugin to the root project; applying to sub projects will result in duplication of the report.
The plugin cannot be used in a project that also uses the new configuration cache (https://docs.gradle.org/7.2/userguide/configuration_cache.html)
When trying to enable the config cache there is a build failure and this message:
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache problems found in this build.
...
- Plugin 'com.asarkar.gradle.build-time-tracker': registration of listener on 'Gradle.addListener' is unsupported
See https://docs.gradle.org/7.2/userguide/configuration_cache.html#config_cache:requirements:build_listeners
My team has some modules that take quite a long time to build. I'd like to enforce a 10 minute build requirement such that builds will fail if they take too long. This plugin seems well-suited to the task; you could just add an optional flag that fails the build if it's above the configured threshold. Default behaviour could continue to be succeeding with info.
My alternative, after some Googling, seems to be to create a build-time-requirement plugin from scratch. It would be a shame though since this plugin already does 90% of what we need.
Let me know your thoughts. Also happy to take a stab at writing the code for this if you'd consider including the feature.
Thanks!
When all the tasks timings are below the threshold, nothing is printed on the output, which may be confusing to the user. Output a log statement to make it clear when this happens.
APIs BuildListener.buildStarted
and Gradle.buildStarted
have been deprecated.
> Task :compileKotlin FAILED
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (26, 69): Cannot access 'toSeconds': it is private in 'Duration'
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (27, 25): Type mismatch: inferred type is Long but BigDecimal! was expected
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (28, 31): Type inference failed. Expected type mismatch: inferred type is Pair<String, BigDecimal!> but Pair<String, Long> was expected
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (39, 41): Cannot access 'toSeconds': it is private in 'Duration'
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (43, 75): Cannot access 'toSeconds': it is private in 'Duration'
e: /Volumes/Workspace/build-time-tracker/src/main/kotlin/org/asarkar/gradle/TimingRecorder.kt: (48, 37): Type mismatch: inferred type is BigDecimal! but Long was expected
> Task :compileTestKotlin FAILED
e: /Volumes/Workspace/build-time-tracker/src/test/kotlin/org/asarkar/gradle/BuildTimeTrackerPluginFunctionalTest.kt: (67, 23): Unresolved reference: readString
The this SO question; Duration.toSeconds
is basically the same as Duration.getSeconds
and was added in Java 9 to avoid confusion.
Files.readString
came in Java 11.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.