Opened 6 years ago

Closed 4 years ago

#1590 closed defect (done)

Counting ExecutionTime may not be safe to date changes

Reported by: abeham Owned by: abeham
Priority: low Milestone: HeuristicLab 3.3.8
Component: Core Version: 3.3.8
Keywords: Cc:

Description (last modified by abeham)

I'm not entirely sure about this and it's a rare case, but since we're using local time to measure it could be possible that we obtain one measurement before a time zone or daylight savings change and the other afterwards. The next daylight savings change is on October 30th, 2011.

We should either use DateTime.UtcNow or the Stopwatch class.

    private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) {
      System.Timers.Timer timer = (System.Timers.Timer)sender;
      timer.Enabled = false;
      DateTime now = DateTime.Now;
      ExecutionTime += now - lastUpdateTime;
      lastUpdateTime = now;
      timer.Enabled = true;
    }

I think we should use the Stopwatch for this kind of task.

Change History (5)

comment:1 Changed 6 years ago by abeham

  • Description modified (diff)

comment:2 Changed 4 years ago by abeham

  • Milestone changed from HeuristicLab 3.3.x Backlog to HeuristicLab 3.3.8
  • Owner changed from swagner to abeham
  • Status changed from new to accepted

comment:3 Changed 4 years ago by abeham

  • Owner changed from abeham to swagner
  • Status changed from accepted to reviewing

r9343: changed date difference calculation to use UTC dates to avoid wrong time spans around daylight savings changes

comment:4 Changed 4 years ago by mkommend

  • Owner changed from swagner to abeham
  • Status changed from reviewing to readytorelease

Reviewed r9343.

comment:5 Changed 4 years ago by swagner

  • Resolution set to done
  • Status changed from readytorelease to closed
  • Version changed from 3.3.5 to 3.3.8
Note: See TracTickets for help on using tickets.