Code Monkey home page Code Monkey logo

maven-buildtime-profiler's Introduction

Maven BuildTime Profiler

Apache License, Version 2.0, January 2004 Maven Central Build Status

Often you have the problem that in large builds, you need to find where time is consumed.

This is an EventSpy implementation which collects all the information of all phases and mojo executions and make a summarization output at the end of the build.

If you like to use this EventSpy with Maven 3.1.1+ till Maven 3.2.5 you need to manually download it from Maven Central and put the resulting jar file into the ${M2_HOME}/lib/ext directory or if you like to use it directly you have to add the following parameter on command line:

mvn -Dmaven.ext.class.path=PathWhereItIsLocated/maven-buildtime-profiler-0.2.0-mvn311.jar clean package

If you like to use this extension for Maven 3.3.1+ you have to define the following .mvn/extensions.xml file:

<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
  <extension>
    <groupId>com.soebes.maven.extensions</groupId>
    <artifactId>maven-buildtime-profiler</artifactId>
    <version>0.2.0</version>
  </extension>
</extensions>

The download from Maven Central will be done by Maven itself.

Here's an example of what the output will look like:

[INFO] ------------------------------------------------------------------------
[INFO] --             Maven Build Time Profiler Summary                      --
[INFO] ------------------------------------------------------------------------
[INFO] Project discovery time:       85 ms
[INFO] ------------------------------------------------------------------------
[INFO] Project Build Time (reactor order):
[INFO]
[INFO] parse-pom:
[INFO]          169 ms : clean
[INFO]          457 ms : process-resources
[INFO]          663 ms : compile
[INFO]           14 ms : process-test-resources
[INFO]          197 ms : test-compile
[INFO]         1109 ms : test
[INFO]         1105 ms : package
[INFO]          811 ms : integration-test
[INFO]           53 ms : verify
[INFO] ------------------------------------------------------------------------
[INFO] Lifecycle Phase summary:
[INFO]
[INFO]      169 ms : clean
[INFO]      457 ms : process-resources
[INFO]      663 ms : compile
[INFO]       14 ms : process-test-resources
[INFO]      197 ms : test-compile
[INFO]     1109 ms : test
[INFO]     1105 ms : package
[INFO]      811 ms : integration-test
[INFO]       53 ms : verify
[INFO] ------------------------------------------------------------------------
[INFO] Plugins in lifecycle Phases:
[INFO]
[INFO] clean:
[INFO]      169 ms: org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean)
[INFO] process-resources:
[INFO]      457 ms: org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources)
[INFO] compile:
[INFO]      663 ms: org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile)
[INFO] process-test-resources:
[INFO]       14 ms: org.apache.maven.plugins:maven-resources-plugin:2.7:testResources (default-testResources)
[INFO] test-compile:
[INFO]      197 ms: org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile)
[INFO] test:
[INFO]     1109 ms: org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test)
[INFO] package:
[INFO]      871 ms: org.apache.maven.plugins:maven-assembly-plugin:2.6:single (make-executable-jar)
[INFO]      234 ms: org.apache.maven.plugins:maven-jar-plugin:2.6:jar (default-jar)
[INFO] integration-test:
[INFO]      811 ms: org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:integration-test (failsafe-integration-test)
[INFO] verify:
[INFO]       53 ms: org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (failsafe-verify)
[INFO] ------------------------------------------------------------------------
[INFO] ForkTime: 0

Most important might be in this relationship that you will get also informations about the time taken to install artifacts:

[INFO] ------------------------------------------------------------------------
[INFO] Installation summary:
[INFO]        0 ms : com.soebes.examples.j2ee:service:1.1.2-SNAPSHOT:pom
[INFO]        1 ms : com.soebes.examples.j2ee:parent:1.1.2-SNAPSHOT:pom
[INFO]        5 ms : com.soebes.examples.j2ee:shade:1.1.2-SNAPSHOT:test:jar
[INFO]        1 ms : com.soebes.examples.j2ee:service-client:1.1.2-SNAPSHOT:pom
[INFO]        0 ms : com.soebes.examples.j2ee:domain:1.1.2-SNAPSHOT:pom
[INFO]        3 ms : com.soebes.examples.j2ee:webgui:1.1.2-SNAPSHOT:pom
[INFO]        1 ms : com.soebes.examples.j2ee:service:1.1.2-SNAPSHOT:jar
[INFO]        0 ms : com.soebes.examples.j2ee:service-client:1.1.2-SNAPSHOT:jar
[INFO]        1 ms : com.soebes.examples.j2ee:domain:1.1.2-SNAPSHOT:jar
[INFO]       10 ms : com.soebes.examples.j2ee:assembly:1.1.2-SNAPSHOT:archive:zip
[INFO]       19 ms : com.soebes.examples.j2ee:assembly:1.1.2-SNAPSHOT:prod:jar
[INFO]        6 ms : com.soebes.examples.j2ee:shade:1.1.2-SNAPSHOT:dev:jar
[INFO]        6 ms : com.soebes.examples.j2ee:shade:1.1.2-SNAPSHOT:prod:jar
[INFO]        1 ms : com.soebes.examples.j2ee:shade:1.1.2-SNAPSHOT:pom
[INFO]        6 ms : com.soebes.examples.j2ee:assembly:1.1.2-SNAPSHOT:dev:jar
[INFO]        1 ms : com.soebes.examples.j2ee:assembly:1.1.2-SNAPSHOT:pom
[INFO]        0 ms : com.soebes.examples.j2ee:appasm:1.1.2-SNAPSHOT:pom
[INFO]        2 ms : com.soebes.examples.j2ee:webgui:1.1.2-SNAPSHOT:war
[INFO]        8 ms : com.soebes.examples.j2ee:app:1.1.2-SNAPSHOT:pom
[INFO]        1 ms : com.soebes.examples.j2ee:shade:1.1.2-SNAPSHOT:jar
[INFO]        3 ms : com.soebes.examples.j2ee:app:1.1.2-SNAPSHOT:ear
[INFO] 75 ms  34,888,754 bytes. 443.633 MiB / s

And much more important are things like the time for the deployment:

[INFO] ------------------------------------------------------------------------
[INFO] Deployment summary:
[INFO]       19 ms : com.soebes.examples.j2ee:assembly:1.1.2-20160306.145402-11:pom
[INFO]       20 ms : com.soebes.examples.j2ee:service-client:1.1.2-20160306.145401-11:jar
[INFO]       80 ms : com.soebes.examples.j2ee:assembly:1.1.2-20160306.145402-11:prod:jar
[INFO]       20 ms : com.soebes.examples.j2ee:shade:1.1.2-20160306.145402-11:pom
[INFO]       19 ms : com.soebes.examples.j2ee:shade:1.1.2-20160306.145402-11:jar
[INFO]       84 ms : com.soebes.examples.j2ee:webgui:1.1.2-20160306.145401-11:war
[INFO]       20 ms : com.soebes.examples.j2ee:service:1.1.2-20160306.145401-11:jar
[INFO]      192 ms : com.soebes.examples.j2ee:assembly:1.1.2-20160306.145402-11:archive:zip
[INFO]       79 ms : com.soebes.examples.j2ee:shade:1.1.2-20160306.145402-11:prod:jar
[INFO]       20 ms : com.soebes.examples.j2ee:webgui:1.1.2-20160306.145401-11:pom
[INFO]       23 ms : com.soebes.examples.j2ee:service-client:1.1.2-20160306.145401-11:pom
[INFO]       90 ms : com.soebes.examples.j2ee:shade:1.1.2-20160306.145402-11:dev:jar
[INFO]       38 ms : com.soebes.examples.j2ee:domain:1.1.2-20160306.145401-11:jar
[INFO]       19 ms : com.soebes.examples.j2ee:appasm:1.1.2-20160306.145402-11:pom
[INFO]       18 ms : com.soebes.examples.j2ee:app:1.1.2-20160306.145401-11:pom
[INFO]      103 ms : com.soebes.examples.j2ee:assembly:1.1.2-20160306.145402-11:dev:jar
[INFO]       39 ms : com.soebes.examples.j2ee:parent:1.1.2-20160306.145401-11:pom
[INFO]      101 ms : com.soebes.examples.j2ee:shade:1.1.2-20160306.145402-11:test:jar
[INFO]       93 ms : com.soebes.examples.j2ee:app:1.1.2-20160306.145401-11:ear
[INFO]       19 ms : com.soebes.examples.j2ee:service:1.1.2-20160306.145401-11:pom
[INFO]       18 ms : com.soebes.examples.j2ee:domain:1.1.2-20160306.145401-11:pom
[INFO] 1,114 ms  34,888,754 bytes. 29.868 MiB / s

Prerequisites minimum for this is Maven 3.1.1+ and Java 1.8 as run time.

If you have ideas for improvements etc. just fill in issues in the tracking system.

maven-buildtime-profiler's People

Contributors

hboutemy avatar khmarbaise avatar recena avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

maven-buildtime-profiler's Issues

[FR] Plugins execution summary

Would it be possible to add "Plugin execution summary"? Currently there is "Lifecycle Phase summary" and details of each plugin execution time within particular lifecycle. It would be great to have a summary of all plugins that got executed and their cumulative time from all lifecycles / modules.

Improvement: output of build times to file instead of console?

For better reporting in CI build jobs, I'd like to dump the information about build times that Maven BuildTime Profiler creates into a file (like maven-build-times.log) instead of, or in addition to, the console. This file can then be archived with the build, analyzed, monitored etc.

For that, I of course don't want to have all the logs going into the file, so simply redirecting stdout is not an option. Also, I probably could configure the Maven logger to dump log output of BuildTimeProfiler class to a file, but that would mean changing the Maven installation's logging configuration (and maybe the SLF4J implementation, too) on all the build nodes... not so cool as well.

I'd rather to do it on a per project level. So the Maven BuildTime Profiler would have to be extended to write the result to a file. Now I wonder whether I could do it depending on any parameter given to the build. Is there any way such a build extension can be passed an argument, in the POM, by command line option or in any other way?

Do you have any other ideas how to satisfy my needs?

seeing NullPointerException when executing maven-dependency-plugin goals

I see a NullPointerException when executing;
mvn dependency:go-offline
or;

$ mvn dependency:resolve -Dclassifier=sources
[INFO] MBTP: Maven Build Time Profiler Version 0.1.0 started.
[INFO] MBTP: workingDirectory: XXX
[INFO] MBTP: multiModuleProjectDirectory: null
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------< tld.example.groupid:maven-buildtime-profiler >------------
[INFO] Building maven-buildtime-profiler 1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:resolve (default-cli) @ maven-buildtime-profiler ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    junit:junit:jar:sources:4.12:test
[INFO]    com.beust:jcommander:jar:sources:1.72:test
[INFO]    org.hamcrest:hamcrest-all:jar:sources:1.3:test
[INFO]    org.apache-extras.beanshell:bsh:jar:sources:2.0b6:test
[INFO]    org.testng:testng:jar:sources:6.14.3:test
[INFO]    org.hamcrest:hamcrest-core:jar:sources:1.3:test
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.958 s
[INFO] Finished at: 2018-04-21T22:44:17+01:00
[INFO] ------------------------------------------------------------------------
[INFO] --             Maven Build Time Profiler Summary                      --
[INFO] ------------------------------------------------------------------------
[INFO] Project discovery time:       77 ms
[INFO] ------------------------------------------------------------------------
[INFO] Project Build Time (reactor order):
[INFO] 
[INFO] maven-buildtime-profiler:
[ERROR] MBTP: Exception
java.lang.NullPointerException
    at com.soebes.maven.extensions.MojoTimer.hasTimeForProjectAndPhase (MojoTimer.java:110)
    at com.soebes.maven.extensions.BuildTimeProfiler.executionResultEventHandler (BuildTimeProfiler.java:398)
    at com.soebes.maven.extensions.BuildTimeProfiler.onEvent (BuildTimeProfiler.java:163)
    at org.apache.maven.eventspy.internal.EventSpyDispatcher.onEvent (EventSpyDispatcher.java:104)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:958)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
$

I'm using the following versions;

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
$ javac -version
javac 1.8.0_162
$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
$ mvn -version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /opt/local/share/java/maven3
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.4", arch: "x86_64", family: "mac"

Upgrade Project

  • Use JUnit Jupiter instead of TestNG
  • Use Awaitility instead of Thread.sleep..
  • Cleaning up code

NullPointerException when calling goals explicitly

In my current project I'm doing a Maven build like this:

mvn clean install site site:stage

It seems the "site:stage" in the end causes a NPE in MojoTimer.java (110) as the collection of phases lifeCyclePhases in BuildTimeProfiller line 394 contains "null" values. Simply adding an "If" check could avoid the error, but I think in this case eventually the code would have to be adjusted to output also stats for the goals not bound to a lifecycle phase.

Strange lifecycle order

Version:0.1.0

Order should be natural or by time consumption

Lifecycle Phase summary:

342 ms : prepare-package
127461 ms : package
2311 ms : install
20353 ms : process-resources
83266 ms : compile
1111 ms : process-test-resources
7717 ms : test-compile
10480 ms : test
17174 ms : generate-resources
1867 ms : process-sources
3465 ms : process-classes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.