Example #1
0
        public static void Main(string[] args)
        {
            MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Map;
            testMsg = AnimalMessage.CreateTestMessage();

            // Warm-up for both
            //TestCli();
            //TestMsgPackSharp();

            // Actual tests...
            TimeTest(TestMsgPackSharp, "Serialize and Deserialize with MsgPack-Sharp");
        }
Example #2
0
        public static void Main(string[] args)
        {
            testMsg = AnimalMessage.CreateTestMessage();

            // Warm-up for both
            //TestCli();
            //TestMsgPackSharp();

            // Actual tests...
            TimeTest(TestCli, "Serialize and Deserialize with Official CLI");
            TimeTest(TestMsgPackSharp, "Serialize and Deserialize with MsgPack-Sharp");
        }
Example #3
0
        public static int Main(string[] args)
        {
            int result = 1;

            if (args[0] == "capturecli")
            {
                AnimalMessage msg        = AnimalMessage.CreateTestMessage();
                var           serializer = MessagePackSerializer.Create <AnimalMessage>();
                using (MemoryStream outStream = new MemoryStream())
                {
                    serializer.Pack(outStream, msg);
                    byte[] output = outStream.ToArray();
                    File.WriteAllBytes("cli.msg", output);
                }
            }
            else
            {
                try
                {
                    byte[] payload = File.ReadAllBytes(args[0]);
                    Console.Out.WriteLine("read " + payload.Length + " bytes");
                    var serializer = MessagePackSerializer.Create <AnimalMessage>();
                    using (MemoryStream stream = new MemoryStream(payload))
                    {
                        var restored = serializer.Unpack(stream);
                        using (MemoryStream outStream = new MemoryStream())
                        {
                            serializer.Pack(outStream, restored);
                            byte[] output = outStream.ToArray();
                            File.WriteAllBytes(args[0] + ".out", output);
                        }
                        result = 0;
                    }
                }
                catch (Exception ex)
                {
                    Console.Out.WriteLine("Error: " + ex);
                }
            }
            return(result);
        }
Example #4
0
 public static void Main(string[] args)
 {
     testMsg = AnimalMessage.CreateTestMessage();
     TimeTest(TestCli, "Serialize and Deserialize with Official CLI");
 }