コード例 #1
0
 public void Run()
 {
     Console.Clear();
     _tumbler    = new Tumbler();
     FixedUpdate = new FixedUpdate {
         UpdateCallback = Step
     };
     while (!_stopToken.IsCancellationRequested)
     {
         FixedUpdate.Tick();
     }
 }
コード例 #2
0
        public static void StressTest(string[] args)
        {
            if (args.Length < 2 || !int.TryParse(args[1], out var count))
            {
                count = 1;
            }

            Console.WriteLine($"Tumbler stress test 2000 step + 2000 steps {count} times");
            var sum1 = 0L;
            var sum2 = 0L;

            //var stress = args[0] == "1";
            //var showProfile = args.Length >= 2 && args[1] == "1";
            for (var i = 0; i < count; i++)
            {
                var test = new Tumbler();
                var t1   = Stopwatch.GetTimestamp();
                for (int j = 0; j < 2000; j++)
                {
                    test.Step();
                }

                t1 = Stopwatch.GetTimestamp() - t1;
                var t2 = Stopwatch.GetTimestamp();
                for (int j = 0; j < 2000; j++)
                {
                    test.Step();
                }

                t2 = Stopwatch.GetTimestamp() - t2;
                Console.WriteLine($"{i + 1}: {t1 / 10000f} ms, {t2 / 10000f} ms");
                sum1 += t1;
                sum2 += t2;
            }

            Console.WriteLine($"Average: {sum1 / (10000f * count)} ms, {sum2 / (10000f * count)} ms");
        }