Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/12/18 13:33:23 (7 years ago)
Author:
abeham
Message:

#1614: Implemented changed behavior to measure execution time (cf. #2869)

Location:
branches/GeneralizedQAP/HeuristicLab.Optimization.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Optimization.Views/3.3/IOptimizerView.Designer.cs

    r14185 r15603  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IOptimizerView));
    4849      this.startButton = new System.Windows.Forms.Button();
     
    5253      this.stopButton = new System.Windows.Forms.Button();
    5354      this.resetButton = new System.Windows.Forms.Button();
     55      this.executionTimer = new System.Windows.Forms.Timer(this.components);
    5456      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5557      this.SuspendLayout();
     
    132134      this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
    133135      //
     136      // executionTimer
     137      //
     138      this.executionTimer.Interval = 200;
     139      this.executionTimer.Tick += new System.EventHandler(this.executionTimer_Tick);
     140      //
    134141      // IOptimizerView
    135142      //
     
    166173    protected System.Windows.Forms.Button pauseButton;
    167174    protected System.Windows.Forms.Button stopButton;
     175    protected System.Windows.Forms.Timer executionTimer;
    168176    protected System.Windows.Forms.Button resetButton;
    169177
  • branches/GeneralizedQAP/HeuristicLab.Optimization.Views/3.3/IOptimizerView.cs

    r15367 r15603  
    4444      Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    4545      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    46       Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    4746      Content.Prepared -= new EventHandler(Content_Prepared);
    4847      Content.Started -= new EventHandler(Content_Started);
     
    5554      Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    5655      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    57       Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
    5856      Content.Prepared += new EventHandler(Content_Prepared);
    5957      Content.Started += new EventHandler(Content_Started);
     
    6462    protected override void OnContentChanged() {
    6563      base.OnContentChanged();
    66       if (Content == null) {
    67         executionTimeTextBox.Text = "-";
    68       } else {
     64      if (Content != null) {
    6965        Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started;
    70         executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    7166      }
     67      UpdateExecutionTime();
    7268    }
    7369
     
    9086      else {
    9187        nameTextBox.Enabled = infoLabel.Enabled = true;
     88        UpdateExecutionTime();
    9289        ReadOnly = Locked = false;
    9390        SetEnabledStateOfExecutableButtons();
     
    9895        Invoke(new EventHandler(Content_Started), sender, e);
    9996      else {
     97        executionTimer.Start();
    10098        nameTextBox.Enabled = infoLabel.Enabled = false;
    10199        ReadOnly = Locked = true;
     
    107105        Invoke(new EventHandler(Content_Paused), sender, e);
    108106      else {
     107        executionTimer.Stop();
     108        UpdateExecutionTime();
    109109        nameTextBox.Enabled = infoLabel.Enabled = true;
    110110        ReadOnly = Locked = false;
     
    116116        Invoke(new EventHandler(Content_Stopped), sender, e);
    117117      else {
     118        executionTimer.Stop();
     119        UpdateExecutionTime();
    118120        nameTextBox.Enabled = infoLabel.Enabled = true;
    119121        ReadOnly = Locked = false;
     
    121123      }
    122124    }
    123     protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    124       if (InvokeRequired)
    125         Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
    126       else
    127         executionTimeTextBox.Text = Content == null ? "-" : Content.ExecutionTime.ToString();
    128     }
    129125    protected virtual void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    130126      if (InvokeRequired)
    131127        Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    132       else
     128      else {
     129        executionTimer.Stop();
     130        UpdateExecutionTime();
    133131        ErrorHandling.ShowErrorDialog(this, e.Value);
     132      }
    134133    }
    135134    #endregion
     
    147146    protected virtual void resetButton_Click(object sender, EventArgs e) {
    148147      Content.Prepare(false);
     148    }
     149    private void executionTimer_Tick(object sender, EventArgs e) {
     150      UpdateExecutionTime();
     151    }
     152
     153    private void UpdateExecutionTime() {
     154      executionTimeTextBox.Text = (Content == null ? "-" : Content.ExecutionTime.ToString());
    149155    }
    150156    #endregion
Note: See TracChangeset for help on using the changeset viewer.