Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8149


Ignore:
Timestamp:
06/28/12 14:57:20 (12 years ago)
Author:
mkommend
Message:

#1884: Adapted measuring the execution time of BatchRuns to behave in a similar way as it is the case of the Experiment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r7576 r8149  
    8181
    8282    [Storable]
     83    private TimeSpan runsExecutionTime;
     84
     85    [Storable]
    8386    private IOptimizer optimizer;
    8487    public IOptimizer Optimizer {
     
    160163      executionState = ExecutionState.Stopped;
    161164      executionTime = TimeSpan.Zero;
     165      runsExecutionTime = TimeSpan.Zero;
    162166      repetitions = 10;
    163167      repetitionsCounter = 0;
     
    169173      executionState = ExecutionState.Stopped;
    170174      executionTime = TimeSpan.Zero;
     175      runsExecutionTime = TimeSpan.Zero;
    171176      repetitions = 10;
    172177      repetitionsCounter = 0;
     
    177182      executionState = ExecutionState.Stopped;
    178183      executionTime = TimeSpan.Zero;
     184      runsExecutionTime = TimeSpan.Zero;
    179185      repetitions = 10;
    180186      repetitionsCounter = 0;
     
    192198      executionState = original.executionState;
    193199      executionTime = original.executionTime;
     200      runsExecutionTime = original.runsExecutionTime;
    194201      optimizer = cloner.Clone(original.optimizer);
    195202      repetitions = original.repetitions;
     
    218225        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    219226      if (Optimizer != null) {
     227        ExecutionTime = TimeSpan.Zero;
    220228        repetitionsCounter = 0;
    221229        if (clearRuns) runs.Clear();
     
    353361    private void Optimizer_Stopped(object sender, EventArgs e) {
    354362      repetitionsCounter++;
     363      ExecutionTime += runsExecutionTime;
     364      runsExecutionTime = TimeSpan.Zero;
    355365
    356366      if (batchRunStopped) OnStopped();
     
    385395    }
    386396    private void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    387       foreach (IRun run in e.OldItems) {
    388         IItem item;
    389         run.Results.TryGetValue("Execution Time", out item);
    390         TimeSpanValue executionTime = item as TimeSpanValue;
    391         if (executionTime != null) ExecutionTime -= executionTime.Value;
    392       }
    393397      if (Optimizer != null) Optimizer.Runs.RemoveRange(e.OldItems);
    394398      foreach (IRun run in e.Items) {
     
    404408        run.Results.TryGetValue("Execution Time", out item);
    405409        TimeSpanValue executionTime = item as TimeSpanValue;
    406         if (executionTime != null) ExecutionTime += executionTime.Value;
     410        if (executionTime != null) {
     411          if (Optimizer.ExecutionState == ExecutionState.Started)
     412            runsExecutionTime += executionTime.Value;
     413          else
     414            ExecutionTime += executionTime.Value;
     415        }
    407416      }
    408417    }
    409418    private void Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    410       foreach (IRun run in e.Items) {
    411         IItem item;
    412         run.Results.TryGetValue("Execution Time", out item);
    413         TimeSpanValue executionTime = item as TimeSpanValue;
    414         if (executionTime != null) ExecutionTime -= executionTime.Value;
    415       }
    416419      if (Optimizer != null) Optimizer.Runs.RemoveRange(e.Items);
    417420    }
Note: See TracChangeset for help on using the changeset viewer.