Changeset 1972 for trunk/eraser
- Timestamp:
- 4/28/2010 6:32:03 AM (3 years ago)
- Location:
- trunk/eraser
- Files:
-
- 3 added
- 3 edited
-
Dependencies/alglib.dll (added)
-
Dependencies/alglib.pdb (added)
-
Eraser.Util/Eraser.Util.csproj (modified) (2 diffs)
-
Eraser.Util/ProgressManager.cs (modified) (5 diffs)
-
Eraser.Util/Sampler.cs (added)
-
Installer/DirectoryStructure.wxs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/Eraser.Util.csproj
r1877 r1972 50 50 </PropertyGroup> 51 51 <ItemGroup> 52 <Reference Include="alglib, Version=2.3.0.0, Culture=neutral, PublicKeyToken=3ac89a0351e689b6, processorArchitecture=MSIL"> 53 <SpecificVersion>False</SpecificVersion> 54 <HintPath>..\Dependencies\alglib.dll</HintPath> 55 </Reference> 52 56 <Reference Include="CommonLibrary, Version=0.9.3.10, Culture=neutral, PublicKeyToken=3ac89a0351e689b6, processorArchitecture=MSIL"> 53 57 <SpecificVersion>False</SpecificVersion> … … 114 118 <Compile Include="NativeMethods\Sfc.cs" /> 115 119 <Compile Include="ProgressManager.cs" /> 120 <Compile Include="Sampler.cs" /> 116 121 <Compile Include="ExtensionClasses\SharingViolationException.cs" /> 117 122 <Compile Include="Shell.cs" /> -
trunk/eraser/Eraser.Util/ProgressManager.cs
r1852 r1972 51 51 { 52 52 StartTime = DateTime.Now; 53 lock (Speeds) 54 Speeds.Reset(); 53 55 } 54 56 … … 87 89 private set; 88 90 } 91 92 /// <summary> 93 /// Samples the current speed of the task. 94 /// </summary> 95 /// <param name="speed">The speed of the task.</param> 96 protected void SampleSpeed(float speed) 97 { 98 lock (Speeds) 99 { 100 IList<KeyValuePair<DateTime, double>> outliers = Speeds.GetOutliers(0.95); 101 if (outliers != null) 102 { 103 List<KeyValuePair<DateTime, double>> recentOutliers = outliers.Where( 104 sample => (DateTime.Now - sample.Key).TotalSeconds <= 60).ToList(); 105 if (recentOutliers.Count >= 5) 106 { 107 Speeds.Reset(); 108 recentOutliers.ForEach(sample => Speeds.Add(sample.Value)); 109 } 110 } 111 112 Speeds.Add(speed); 113 PredictedSpeed = Speeds.Predict(0.95); 114 } 115 } 116 117 /// <summary> 118 /// Predicts the speed of the operation, given the current samples. 119 /// </summary> 120 protected Interval PredictedSpeed 121 { 122 get; 123 private set; 124 } 125 126 /// <summary> 127 /// The speed sampler. 128 /// </summary> 129 private Sampler Speeds = new Sampler(); 89 130 } 90 131 … … 170 211 171 212 //Then compute the speed of the calculation 172 lastSpeed = (float)((Completed - lastCompleted) / timeElapsed / total); 213 long progressDelta = Completed - lastCompleted; 214 float currentSpeed = (float)(progressDelta / timeElapsed / total); 173 215 lastSpeedCalc = DateTime.Now; 174 216 lastCompleted = Completed; 217 218 //We won't update the speed of the task if the current speed is within 219 //the lower and upper prediction interval. 220 Interval interval = PredictedSpeed; 221 if (interval != null) 222 { 223 if (currentSpeed < interval.Minimum) 224 { 225 Restart(); 226 lastSpeed = currentSpeed; 227 } 228 else if (currentSpeed > interval.Maximum) 229 { 230 Restart(); 231 lastSpeed = currentSpeed; 232 } 233 else if (lastSpeed == 0.0f) 234 { 235 lastSpeed = currentSpeed; 236 } 237 } 238 239 SampleSpeed(currentSpeed); 175 240 return lastSpeed; 176 241 } … … 421 486 get 422 487 { 423 if (CurrentStep == null) 424 return 0; 425 426 return CurrentStep.Progress.Speed; 488 if ((DateTime.Now - lastSpeedCalc).TotalSeconds < SpeedCalcInterval) 489 return lastSpeed; 490 491 //Calculate how much time has passed 492 double timeElapsed = (DateTime.Now - lastSpeedCalc).TotalSeconds; 493 494 //Then compute the speed of the calculation 495 float currentProgress = Progress; 496 float progressDelta = currentProgress - lastCompleted; 497 float currentSpeed = (float)(progressDelta / timeElapsed); 498 lastSpeedCalc = DateTime.Now; 499 lastCompleted = Progress; 500 501 //If the progress delta is zero, it usually means that the amount 502 //completed within the calculatin interval is too short -- lengthen 503 //the interval so we can get a small difference, significant to make 504 //a speed calculation. Likewise, if it is too great a difference, 505 //we need to shorten the interval to get more accurate calculations 506 if (progressDelta == 0.0) 507 SpeedCalcInterval *= 2; 508 else if (progressDelta > 3.0) 509 SpeedCalcInterval -= 3; 510 511 //We won't update the speed of the task if the current speed is within 512 //the lower and upper prediction interval. 513 Interval interval = PredictedSpeed; 514 if (interval != null) 515 { 516 if (currentSpeed < interval.Minimum) 517 { 518 Restart(); 519 lastSpeed = currentSpeed; 520 } 521 else if (currentSpeed > interval.Maximum) 522 { 523 Restart(); 524 lastSpeed = currentSpeed; 525 } 526 else if (lastSpeed == 0.0f) 527 { 528 lastSpeed = currentSpeed; 529 } 530 } 531 532 SampleSpeed(currentSpeed); 533 return lastSpeed; 427 534 } 428 535 } … … 487 594 /// </summary> 488 595 private object ListLock; 596 597 /// <summary> 598 /// The amount of time elapsed before a new speed calculation is made. 599 /// </summary> 600 private int SpeedCalcInterval = 15; 601 602 /// <summary> 603 /// The last time a speed calculation was computed so that speed is not 604 /// computed too often. 605 /// </summary> 606 private DateTime lastSpeedCalc; 607 608 /// <summary> 609 /// The amount of the operation completed at the last speed computation. 610 /// </summary> 611 private float lastCompleted; 612 613 /// <summary> 614 /// The last calculated speed of the operation. 615 /// </summary> 616 private float lastSpeed; 489 617 } 490 618 -
trunk/eraser/Installer/DirectoryStructure.wxs
r1949 r1972 55 55 Type="string" Value="[!EraserExe]" /> 56 56 57 <File Id="Alglib" Name="alglib.dll" Source="..\bin\Release\alglib.dll" 58 ProcessorArchitecture="msil" /> 57 59 <File Id="BevelLine" Name="BevelLine.dll" Source="..\bin\Release\BevelLine.dll" 58 60 ProcessorArchitecture="msil" />
Note: See TracChangeset
for help on using the changeset viewer.
