public void ConvertTime()
        {
            HighResolutionTimer timer = new HighResolutionTimer();

            timer.Start();
            Wait();
            timer.Stop();

            double duration = timer.Duration(1);
            Assert.Between(
                HighResolutionTimer.TimeToMilliseconds(duration),
                duration * TimeToMilliseconds * (1.0 - Variation),
                duration * TimeToMilliseconds * (1.0 + Variation)
            );
            Assert.Between(
                HighResolutionTimer.TimeToSeconds(duration),
                duration * TimeToSeconds * (1.0 - Variation),
                duration * TimeToSeconds * (1.0 + Variation)
            );
            Assert.Between(
                HighResolutionTimer.TimeToTimeSpan(duration).TotalSeconds,
                duration * TimeToSeconds * (1.0 - Variation),
                duration * TimeToSeconds * (1.0 + Variation)
            );
        }
        public void MeasureCallTime()
        {
            // Warm up
            HighResolutionTimer.Sample();

            TimerSample start = HighResolutionTimer.Sample();
            TimerSample end = HighResolutionTimer.Sample();
            Console.WriteLine(HighResolutionTimer.Duration(start, end));

            HighResolutionTimer timer = new HighResolutionTimer();
            timer.Start();
            timer.Stop();
            Console.WriteLine(timer.Duration(1));
        }
        public void StartStop()
        {
            HighResolutionTimer timer = new HighResolutionTimer();

            timer.Start();
            double elapsedTime = Wait();
            timer.Stop();

            double duration = timer.Duration(1) * TimeToMilliseconds;

            Console.WriteLine("DateTime time: {0:N3}, Timer time: {1:N3}", elapsedTime, duration);

            Assert.Between(
                duration,
                elapsedTime * (1.0 - Variation),
                elapsedTime * (1.0 + Variation)
            );
        }