Ejemplo n.º 1
0
        void RunTimed()
        {
            var loop = new Loop();

            this.idle = loop.CreateIdle();
            this.idle.Start(this.OnIdleTimedCallback);

            Timer timer = loop.CreateTimer();

            timer.Start(this.OnTimerCallback, 5000, 0);

            loop.RunDefault();
            Console.WriteLine($"Loop count timed : {this.ticks} ticks ({this.ticks / 0.5} ticks/s).");

            this.idle.Dispose();
            loop.Dispose();
        }
Ejemplo n.º 2
0
        void RunTimed()
        {
            var loop = new Loop();

            this.idle = loop.CreateIdle();
            this.idle.Start(this.OnIdleTimedCallback);

            Timer timer = loop.CreateTimer();

            timer.Start(this.OnTimerCallback, 5000, 0);

            loop.RunDefault();
            double value = this.ticks / 0.5;

            Console.WriteLine($"Loop count timed : {TestHelper.Format(this.ticks)} ticks ({TestHelper.Format(value)} ticks/s).");

            this.idle.Dispose();
            loop.Dispose();
        }
Ejemplo n.º 3
0
        void RunCount()
        {
            var loop = new Loop();

            this.idle = loop.CreateIdle();
            this.idle.Start(this.OnIdleTickCallback);

            long start = loop.NowInHighResolution;

            loop.RunDefault();
            long   stop           = loop.NowInHighResolution;
            long   duration       = stop - start;
            double seconds        = (double)duration / NanoSeconds;
            long   ticksPerSecond = (long)Math.Floor(NumberOfTicks / seconds);

            Console.WriteLine($"Loop count : {NumberOfTicks} ticks in {seconds} seconds ({ticksPerSecond}/s).");

            this.idle.Dispose();
            loop.Dispose();
        }