欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Time - Time-interval Measurements

程序员文章站 2022-12-15 18:16:25
```c# public class TimeHelper { private long _start, _stop, _elapsed; /// /// 获取初始时间戳 /// public void start() { _start = Stopwatch.GetTimestamp(); } /... ......
public class timehelper
{
    private long _start, _stop, _elapsed;

    /// <summary>
    /// 获取初始时间戳
    /// </summary>
    public void start()
    {
        _start = stopwatch.gettimestamp();
    }

    /// <summary>
    /// 获取终结时间戳
    /// </summary>
    public void stop()
    {
        _stop = stopwatch.gettimestamp();
    }

    /// <summary>
    /// 获取高精度时间间隔
    /// </summary>
    /// <returns></returns>
    public double gettimeinteval()
    {
        return (_stop - _start) * (1.0 / stopwatch.frequency);
    }
}