コード例 #1
0
ファイル: TestCollection.cs プロジェクト: Khazuar/BOS
        public static void ShipTypeVerifierPerformanceTest()
        {
            var data = new bool[500, 500, 1];

            for (int x = 0; x < 150; x++)
                for (int y = 0; y < 150; y++)
                    data[x, y, 0] = true;
            var AShipType = new ShipType(data, 1, "Test", 1);

            Console.WriteLine("Hello!");

            var sw = new Stopwatch();

            double times = 0;
            int runs = 100;
            for (int i = 0; i < runs; ++i) {
                sw.Start();
                Console.WriteLine("IsValid: " + AShipType.IsValid);
                sw.Stop();
                times += sw.Elapsed.TotalMilliseconds;
                Console.WriteLine("Time: " + sw.Elapsed.TotalMilliseconds.ToString() + "ms");
                sw.Reset();
                Console.WriteLine("===================================================");
                Console.WriteLine();
            }

            Console.WriteLine("average time: " + (times / runs).ToString() + "ms");
        }
コード例 #2
0
ファイル: TestCollection.cs プロジェクト: Khazuar/BOS
        public static void ShipTypeJsonEqualityTest()
        {
            var data = new bool[5, 5, 1];

            for (int x = 1; x < 3; x++)
                for (int y = 0; y < 4; y++)
                    data[x, y, 0] = true;
            var AShipType = new ShipType(data, 2, "Test", 5);

            var jsonO = KhazJson.JSON.Serialize(AShipType);
            var jsonS = jsonO.ParseToString();

            Console.WriteLine(jsonS);
            Console.WriteLine();

            jsonO = KhazJson.JSON.ParseFromString(jsonS);

            var BShipType = KhazJson.JSON.Deserialize<ShipType>(jsonO);

            Console.WriteLine(AShipType.Print());
            Console.WriteLine(BShipType.Print());
            Console.WriteLine("Equal String: " + (AShipType.Print() == BShipType.Print()));
            Console.WriteLine("Equal: " + (AShipType.Equals(BShipType)));
        }