Changeset 4086
- Timestamp:
- Dec 21, 2010, 1:52:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin/src/org/proteios/plugins/RunMsInspectPlugin.java
r4083 r4086 224 224 private int byteBufferSize = BYTE_BUFFER_SIZE_DEFAULT; 225 225 /* 226 * Size of input file in bytes. 227 */ 228 private long inputFileSizeInBytes = 0; 229 /* 226 230 * Flag indicating aborted job. 227 231 */ … … 250 254 { 251 255 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; 252 278 } 253 279 … … 392 418 File spectrumFile = factory.getById(File.class, spectrumFileId); 393 419 log.debug("spectrumFile (original) = " + spectrumFile); 420 // Get spectrum file size in bytes for progress calculation 421 long fileSizeInBytes = spectrumFile.getSizeInBytes(); 422 setInputFileSizeInBytes(fileSizeInBytes); 394 423 // Always use original spectrum filename, even if a converted file is used for msInspect feature detection 395 424 String originalSpectrumFilename = spectrumFile.getName(); … … 745 774 if (progress != null) 746 775 { 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 749 833 // msInspect typically outputs a line like "16 Dec 2010 11:02:02,965 INFO ApplicationContext: 12.043658% complete." 750 834 String testStr = new String("ApplicationContext: "); … … 753 837 { 754 838 // 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()); 756 841 /* 757 842 System.out 758 .println(this.getClass().getSimpleName() + ": percentStr (1) = \"" + percentStr + "\"");843 .println(this.getClass().getSimpleName() + ": analysisPercentStr (1) = \"" + analysisPercentStr + "\""); 759 844 */ 760 845 testStr = new String("."); 761 index = percentStr.indexOf(testStr);846 index = analysisPercentStr.indexOf(testStr); 762 847 if (index >= 0) 763 848 { 764 849 // 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); 766 852 /* 767 853 System.out … … 769 855 */ 770 856 // Convert percent string to int 771 int percentCompleted = 0;857 int analysisPercentCompleted = 0; 772 858 try 773 859 { 774 percentCompleted = Integer.parseInt(percentStr);860 analysisPercentCompleted = Integer.parseInt(percentStr); 775 861 } 776 862 catch (NumberFormatException e) 777 863 {} 864 // Construct progress message 865 // Example; progressMessage = "Analysis: 12.043658% complete." 866 String progressMessage = new String("Analysis: " + analysisPercentStr); 778 867 // Total progress includes more than msInspect analysis 868 int percentCompleted = EstimatedTotalPercentage(analysisPercentCompleted, true); 779 869 if (percentCompleted > 99) 780 870 { 781 871 percentCompleted = 99; 782 872 } 783 progress.display(percentCompleted, "% completed");873 progress.display(percentCompleted, progressMessage); 784 874 } 785 875 } 786 876 } 787 877 } 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; 788 919 } 789 920
Note: See TracChangeset
for help on using the changeset viewer.