Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
AbsoluteStopwatch.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Diagnostics;
8 
9 namespace SiliconStudio.Paradox.Games.Time
10 {
11  /// <summary>
12  /// Represent an absolute time measurement stopwatch. (with as few internal overhead as possible)
13  /// It measures elapsed time in seconds between calls to Start method and Elapsed property.
14  /// </summary>
15  public class AbsoluteStopwatch
16  {
17  private long startTicks;
18 
19  /// <summary>
20  /// Start the stopwatch. (use this method also to restart stopwatching)
21  /// </summary>
22  public void Start()
23  {
24  startTicks = Stopwatch.GetTimestamp();
25  }
26 
27  /// <summary>
28  /// Gets the time elapsed since previous call to Start method, in seconds.
29  /// </summary>
30  public double Elapsed
31  {
32  get
33  {
34  long elapsed = Stopwatch.GetTimestamp() - startTicks;
35  if (elapsed < 0)
36  return 0.0;
37  return (double)elapsed / (Stopwatch.Frequency);
38  }
39  }
40  }
41 }
Represent an absolute time measurement stopwatch. (with as few internal overhead as possible) It meas...
void Start()
Start the stopwatch. (use this method also to restart stopwatching)