Exemplo n.º 1
0
        static void Main(string[] args)
        {
            data = new KinectData[arraySize];
            for (int i = 0; i < arraySize; i++)
            {
                data[i] = new KinectData(i, new Position(1, 2, 3), "KinectData");
            }

            Console.WriteLine("Serialisation for " + arraySize + " array size");
            Console.WriteLine("Serialized " + timesSerialized + " times");
            Console.WriteLine("-------------------------------------------- \n");

            stopwatch.Reset();



            stopwatch.Start();
            for (int i = 0; i < timesSerialized; i++)
            {
                protobufSerialize();
                resetData();
            }
            stopwatch.Stop();
            timeProtobuf = stopwatch.ElapsedMilliseconds;
            stopwatch.Reset();

            Console.WriteLine("Protobuf average results");
            Console.WriteLine("_______________________");
            Console.WriteLine("Time: " + timeProtobuf / timesSerialized + " ms with " + sizeProtobuf / timesSerialized + " bytes \n \n");

            stopwatch.Start();
            for (int i = 0; i < timesSerialized; i++)
            {
                binaryFormatterSerialize();
                resetData();
            }
            stopwatch.Stop();
            timeBinaryFormatter = stopwatch.Elapsed.TotalMilliseconds;
            stopwatch.Reset();

            Console.WriteLine("BinaryFormatter average results");
            Console.WriteLine("_______________________");
            Console.WriteLine("Time: " + (timeBinaryFormatter / timesSerialized) + " ms with " + sizeBinaryFormatter / timesSerialized + " bytes \n \n");

            stopwatch.Start();
            for (int i = 0; i < timesSerialized; i++)
            {
                jsonSerialize();
                resetData();
            }
            stopwatch.Stop();
            timeJson = stopwatch.Elapsed.TotalMilliseconds;
            stopwatch.Reset();

            Console.WriteLine("Json average results");
            Console.WriteLine("_______________________");
            Console.WriteLine("Time: " + timeJson / timesSerialized + " ms with " + sizeJson / timesSerialized + " bytes \n \n");


            Console.ReadLine();
        }
Exemplo n.º 2
0
 public KinectData(KinectData kinectData)
 {
     this.position = kinectData.position;
     this.dataType = kinectData.dataType;
     this.position = kinectData.position;
 }