Пример #1
0
        private static ulong GetCyclesPerSeond()
        {
            Rdtsc.Init();

            var sw      = Stopwatch.StartNew();
            var startms = Rdtsc.TimestampP();

            do
            {
            } while (sw.ElapsedMilliseconds < 1000);
            var endms           = Rdtsc.TimestampP();
            var cyclesPerSecond = (endms - startms);

            return(cyclesPerSecond);
        }
Пример #2
0
 public AutoStopWatch(string message, double repeats, Action <string> reporter)
 {
     _message              = message;
     _repeats              = repeats;
     _reporter             = reporter;
     _nanoSecondPerCycle   = NanoSecondsPerSecond / CyclesPerSecond;
     _microSecondsPerCycle = MicroSecondsPerSecond / CyclesPerSecond;
     _milliSecondsPerCycle = MilliSecondsPerSecond / CyclesPerSecond;
     Rdtsc.Init();
     _startTest = Rdtsc.TimestampP();
     if (_showInfo)
     {
         _reporter(string.Format($"cycles per second: {CyclesPerSecond,5:0} "));
         _reporter(string.Format($"{NanoSecondsPerSecond / CyclesPerSecond,5:0.000} ns per cycle"));
         _showInfo = false;
     }
 }