Exemplo n.º 1
0
        static void SpeedTest()
        {
            PowerSerializer ser          = new PowerSerializer(new FullGuidTypeResolver());
            Cat <int>       cat          = new Cat <int>();
            BinaryFormatter bf           = new BinaryFormatter();
            MemoryStream    memorystream = new MemoryStream();

            bf.Serialize(memorystream, cat);
            byte[] compettee = memorystream.ToArray();
            byte[] pb        = ser.Serialize(cat);
            for (int i = 0; i < WARM; i++)
            {
            }

            DateTime start = DateTime.Now;

            for (int i = 0; i < THRESH; i++)
            {
                ser.Serialize(cat);
            }
            TimeSpan pTime = DateTime.Now - start;

            start = DateTime.Now;
            for (int i = 0; i < THRESH; i++)
            {
                memorystream = new MemoryStream();
                bf.Serialize(memorystream, cat);
            }
            TimeSpan sTime = DateTime.Now - start;


            Console.WriteLine("Total time for p: " + pTime.TotalMilliseconds + " and for s: " + sTime.TotalMilliseconds);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PowerSerializer ser = new PowerSerializer();

            byte[] data = ser.Serialize(new Container()
            {
                Yert = new[] { typeof(string) }
            });
            object deserialized = ser.Deserialize(data);

            Console.ReadKey();
        }