Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5729

Measure (build time) durations with System.nanoTime only

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

      Description

      Currently, we solely rely on System.currentTimeMillis to track start/end times as well as durations. This is error prone and not guaranteed to deliver a monotic value with positive durations.

      We should consider employing System.nanoTime throughout the core where the above mentioned conditions are met. E.g., in some of:

      maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime();
      maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java: this.transferStartTime = System.currentTimeMillis();
      maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java: long buildEndTime = System.currentTimeMillis();
      maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java: long buildStartTime = System.currentTimeMillis();
      maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java: long buildEndTime = System.currentTimeMillis();
      maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java: long finish = System.currentTimeMillis();
      maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime();
      maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime();
      DefaultMaven.java: request.setStartTime( new Date() ); 
      DefaultMavenExecutionRequest.java: public Date getStartTime() 
      DefaultMavenExecutionRequest.java: projectBuildingRequest.setBuildStartTime( getStartTime() ); 
      MavenExecutionRequest.java: Date getStartTime(); 
      MavenSession.java: public Date getStartTime() 
      MavenSession.java: return request.getStartTime(); 
      ExecutionEventLogger.java: long time = finish - session.getRequest().getStartTime().getTime(); 
      

      and all other code spots where Date or long is used.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              michael-o Michael Osipov

              Dates

              • Created:
                Updated:

                Issue deployment