Changeset 4086


Ignore:
Timestamp:
Dec 21, 2010, 1:52:03 PM (12 years ago)
Author:
olle
Message:

Refs #668. Class/file plugins/RunMsInspectPlugin.java in plugin/ updated to improve job progress message and percentage information:

  1. New private instance variable long inputFileSizeInBytes added, with public accessor methods. It is used to store the size of the input spectrum file in bytes for estimation of fraction of time spent in different process phases. This data is used for progress information.
  1. Private method void msInspectSearchLocal(Request request, Response response, ProgressReporter progress, ...) updated to obtain the size of the input spectrum file in bytes and store it in new instance variable inputFileSizeInBytes.
  1. Private method void updateProgressInformation(ProgressReporter progress, String line) updated to parse the input string for progress information in the indexing and analysis phases. Calls new private method int EstimatedTotalPercentage(int percentage, boolean isAnalysisPhase) to get the estimated total percentage from percentage values for the two different phases.
  1. New private method int EstimatedTotalPercentage(int percentage, boolean isAnalysisPhase) added. It estimates total percentage of time to completion. Assumes two phases, an indexing phase and an analysis phase. Estimates the fraction of time spent in the indexing phase and analysis phase from the size of the input file, based on test runs with input files of different sizes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/src/org/proteios/plugins/RunMsInspectPlugin.java

    r4083 r4086  
    224224  private int byteBufferSize = BYTE_BUFFER_SIZE_DEFAULT;
    225225  /*
     226   * Size of input file in bytes.
     227   */
     228  private long inputFileSizeInBytes = 0;
     229  /*
    226230   * Flag indicating aborted job.
    227231   */
     
    250254  {
    251255    this.byteBufferSize = byteBufferSize;
     256  }
     257
     258
     259  /**
     260   * Get size of input file in bytes.
     261   *
     262   * @return long Size of input file in bytes.
     263   */
     264  public long getInputFileSizeInBytes()
     265  {
     266    return this.inputFileSizeInBytes;
     267  }
     268
     269
     270  /**
     271   * Set size of input file in bytes.
     272   *
     273   * @param inputFilesizeInBytes long Size of input file in bytes to set.
     274   */
     275  public void setInputFileSizeInBytes(long inputFileSizeInBytes)
     276  {
     277    this.inputFileSizeInBytes = inputFileSizeInBytes;
    252278  }
    253279
     
    392418    File spectrumFile = factory.getById(File.class, spectrumFileId);
    393419    log.debug("spectrumFile (original) = " + spectrumFile);
     420    // Get spectrum file size in bytes for progress calculation
     421    long fileSizeInBytes = spectrumFile.getSizeInBytes();
     422    setInputFileSizeInBytes(fileSizeInBytes);
    394423    // Always use original spectrum filename, even if a converted file is used for msInspect feature detection
    395424    String originalSpectrumFilename = spectrumFile.getName();
     
    745774    if (progress != null)
    746775    {
    747       if (line.contains("complete"))
    748       {
     776      if (line.contains("Building index file: "))
     777      {
     778        // msInspect indexing phase
     779        // msInspect typically outputs a line like "16 Dec 2010 11:01:54,145 INFO  ApplicationContext: Building index file: 11%"
     780        String testStr = new String("ApplicationContext: ");
     781        int index = line.indexOf(testStr);
     782        if (index >= 0)
     783        {
     784          // Cut off start of string including testStr
     785          // Example: indexingMessageStr = "Building index file: 11%"
     786          String indexingMessageStr = line.substring(index + testStr.length());
     787          /*
     788          System.out
     789            .println(this.getClass().getSimpleName() + ": indexingMessageStr (1) = \"" + indexingMessageStr + "\"");
     790          */
     791          testStr = new String("Building index file: ");
     792          index = indexingMessageStr.indexOf(testStr);
     793          if (index >= 0)
     794          {
     795            // Cut off start of string including testStr
     796            // Example: indexingPercentStr = "11%"
     797            String indexingPercentStr = indexingMessageStr.substring(index + testStr.length());
     798            testStr = new String("%");
     799            index = indexingPercentStr.indexOf(testStr);
     800            if (index >= 0)
     801            {
     802              // Cut off end of string starting with testStr
     803              String percentStr = indexingPercentStr.substring(0, index);
     804              /*
     805              System.out
     806                .println(this.getClass().getSimpleName() + ": percentStr (2) = \"" + percentStr + "\"");
     807              */
     808              // Convert percent string to int
     809              int indexingPercentCompleted = 0;
     810              try
     811              {
     812                indexingPercentCompleted = Integer.parseInt(percentStr);
     813              }
     814              catch (NumberFormatException e)
     815              {}
     816              // Construct progress message
     817              // Example; progressMessage = "Building index file: 11%""
     818              String progressMessage = new String(indexingMessageStr);
     819              // Total progress includes more than msInspect analysis
     820              int percentCompleted = EstimatedTotalPercentage(indexingPercentCompleted, false);
     821              if (percentCompleted > 99)
     822              {
     823                percentCompleted = 99;
     824              }
     825              progress.display(percentCompleted, progressMessage);
     826            }
     827          }
     828        }
     829      }
     830      else if (line.contains("complete"))
     831      {
     832        // msInspect analysis phase
    749833        // msInspect typically outputs a line like "16 Dec 2010 11:02:02,965 INFO  ApplicationContext: 12.043658% complete."
    750834        String testStr = new String("ApplicationContext: ");
     
    753837        {
    754838          // Cut off start of string including testStr
    755           String percentStr = line.substring(index + testStr.length());
     839          // Example: analysisPercentStr = "12.043658% complete."
     840          String analysisPercentStr = line.substring(index + testStr.length());
    756841          /*
    757842          System.out
    758             .println(this.getClass().getSimpleName() + ": percentStr (1) = \"" + percentStr + "\"");
     843            .println(this.getClass().getSimpleName() + ": analysisPercentStr (1) = \"" + analysisPercentStr + "\"");
    759844          */
    760845          testStr = new String(".");
    761           index = percentStr.indexOf(testStr);
     846          index = analysisPercentStr.indexOf(testStr);
    762847          if (index >= 0)
    763848          {
    764849            // Cut off end of string starting with testStr
    765             percentStr = percentStr.substring(0, index);
     850            // Example: percentStr = "12"
     851            String percentStr = analysisPercentStr.substring(0, index);
    766852            /*
    767853            System.out
     
    769855            */
    770856            // Convert percent string to int
    771             int percentCompleted = 0;
     857            int analysisPercentCompleted = 0;
    772858            try
    773859            {
    774               percentCompleted = Integer.parseInt(percentStr);
     860              analysisPercentCompleted = Integer.parseInt(percentStr);
    775861            }
    776862            catch (NumberFormatException e)
    777863            {}
     864            // Construct progress message
     865            // Example; progressMessage = "Analysis: 12.043658% complete."
     866            String progressMessage = new String("Analysis: " + analysisPercentStr);
    778867            // Total progress includes more than msInspect analysis
     868            int percentCompleted = EstimatedTotalPercentage(analysisPercentCompleted, true);
    779869            if (percentCompleted > 99)
    780870            {
    781871              percentCompleted = 99;
    782872            }
    783             progress.display(percentCompleted, "% completed");
     873            progress.display(percentCompleted, progressMessage);
    784874          }
    785875        }
    786876      }
    787877    }
     878  }
     879
     880
     881  /**
     882   * Estimates total percentage of time to completion.
     883   * Assumes two phases, an indexing phase and an analysis phase.
     884   * Estimates the fraction of time spent in the indexing phase
     885   * and analysis phase from the size of the input file,
     886   * based on test runs with input files of different sizes.
     887   *
     888   * @param percentage int Percentage in current phase.
     889   * @param isAnalysisPhase boolean Flag indication if process is in analysis phase.
     890   * @return int The estimated total percentage of time to completion.
     891   */
     892  private int EstimatedTotalPercentage(int percentage, boolean isAnalysisPhase)
     893  {
     894    // Get input file size in bytes for progress calculation
     895    long fileSizeInBytes = getInputFileSizeInBytes();
     896    double analysisIndexingRatio = ((double) fileSizeInBytes)/(1024.0*1024.0) * 0.066;
     897    if (analysisIndexingRatio < 1.0)
     898    {
     899      analysisIndexingRatio = 1.0;
     900    }
     901    double phaseFraction = ((double) percentage)/100.0;
     902    if (phaseFraction > 1.0)
     903    {
     904      phaseFraction = 1.0;
     905    }
     906    double totalFraction = phaseFraction/(1.0 + analysisIndexingRatio);
     907    if (isAnalysisPhase)
     908    {
     909      totalFraction = (1.0 + phaseFraction*analysisIndexingRatio)/(1.0 + analysisIndexingRatio);
     910    }
     911    if (totalFraction > 1.0)
     912    {
     913      totalFraction = 1.0;
     914    }
     915    double totalPercentage = 100.0*totalFraction;
     916    int totalIntegerPercentage = (int) totalPercentage;
     917    System.out.println(this.getClass().getSimpleName() + ": percentage = " + percentage + " isAnalysisPhase = " + isAnalysisPhase + " fileSizeInBytes = " + fileSizeInBytes + " analysisIndexingRatio = " + analysisIndexingRatio + " totalPercentage = " + totalPercentage + " totalIntegerPercentage = " + totalIntegerPercentage);
     918    return totalIntegerPercentage;
    788919  }
    789920
Note: See TracChangeset for help on using the changeset viewer.