public void Benchmark()
        {
            new System.Xml.Serialization.XmlSerializer(typeof(JitPreparation), null, null, null, null);
            CustomSerializer.GetSerializer(typeof(JitPreparation), null, TestXmlSerializerOptions.Empty);

            var containerWithAbstract =
                new ColdStartContainerWithAbstract
            {
                Id  = "a",
                One =
                    new ColdStartOneWithAbstract
                {
                    Id  = "b",
                    Two = new ColdStartTwoWithAbstract {
                        Id = "c", Value = "abc"
                    }
                }
            };
            var containerWithInterface =
                new ColdStartContainerWithInterface
            {
                Id  = "a",
                One =
                    new ColdStartOneWithInterface
                {
                    Id  = "b",
                    Two = new ColdStartTwoWithInterface {
                        Id = "c", Value = "abc"
                    }
                }
            };

            var xmlSerializerStopwatch = Stopwatch.StartNew();

            var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(ColdStartContainerWithAbstract), null, null, null, null);
            var xmlSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(xmlSerializerStringBuilder))
            {
                using (var writer = new XmlTextWriter(stringWriter))
                {
                    xmlSerializer.Serialize(writer, containerWithAbstract, null);
                }
            }

            using (var stringReader = new StringReader(xmlSerializerStringBuilder.ToString()))
            {
                using (var reader = new XmlTextReader(stringReader))
                {
                    xmlSerializer.Deserialize(reader);
                }
            }

            xmlSerializerStopwatch.Stop();

            ISerializeOptions options = new TestSerializeOptions();

            var customSerializerStopwatch = Stopwatch.StartNew();

            var customSerializer = CustomSerializer.GetSerializer(typeof(ColdStartContainerWithInterface), null, TestXmlSerializerOptions.Empty);
            var customSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(customSerializerStringBuilder))
            {
                using (var writer = new XSerializerXmlTextWriter(stringWriter, options))
                {
                    customSerializer.SerializeObject(writer, containerWithInterface, new TestSerializeOptions(true));
                }
            }

            using (var stringReader = new StringReader(customSerializerStringBuilder.ToString()))
            {
                using (var xmlReader = new XmlTextReader(stringReader))
                {
                    using (var reader = new XSerializerXmlReader(xmlReader, options.GetEncryptionMechanism(), options.EncryptKey, options.SerializationState))
                    {
                        customSerializer.DeserializeObject(reader, options);
                    }
                }
            }

            customSerializerStopwatch.Stop();

            Console.WriteLine("XmlSerializer Elapsed Time: {0}", xmlSerializerStopwatch.Elapsed);
            Console.WriteLine("CustomSerializer Elapsed Time: {0}", customSerializerStopwatch.Elapsed);
        }
        public void Benchmark()
        {
            new XmlSerializer(typeof(JitPreparation), null, null, null, null);
            CustomSerializer.GetSerializer(typeof(JitPreparation), null, null, null);

            var containerWithAbstract =
                new ColdStartContainerWithAbstract
                {
                    Id = "a",
                    One =
                        new ColdStartOneWithAbstract
                        {
                            Id = "b",
                            Two = new ColdStartTwoWithAbstract { Id = "c", Value = "abc" }
                        }
                };
            var containerWithInterface =
                new ColdStartContainerWithInterface
                {
                    Id = "a",
                    One =
                        new ColdStartOneWithInterface
                        {
                            Id = "b",
                            Two = new ColdStartTwoWithInterface { Id = "c", Value = "abc" }
                        }
                };

            var xmlSerializerStopwatch = Stopwatch.StartNew();

            var xmlSerializer = new XmlSerializer(typeof(ColdStartContainerWithAbstract), null, null, null, null);
            var xmlSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(xmlSerializerStringBuilder))
            {
                using (var writer = new XmlTextWriter(stringWriter))
                {
                    xmlSerializer.Serialize(writer, containerWithAbstract, null);
                }
            }

            using (var stringReader = new StringReader(xmlSerializerStringBuilder.ToString()))
            {
                using (var reader = new XmlTextReader(stringReader))
                {
                    xmlSerializer.Deserialize(reader);
                }
            }

            xmlSerializerStopwatch.Stop();

            var customSerializerStopwatch = Stopwatch.StartNew();

            var customSerializer = CustomSerializer.GetSerializer(typeof(ColdStartContainerWithInterface), null, null, null);
            var customSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(customSerializerStringBuilder))
            {
                using (var writer = new SerializationXmlTextWriter(stringWriter))
                {
                    customSerializer.SerializeObject(writer, containerWithInterface, null, false);
                }
            }

            using (var stringReader = new StringReader(customSerializerStringBuilder.ToString()))
            {
                using (var reader = new XmlTextReader(stringReader))
                {
                    customSerializer.DeserializeObject(reader);
                }
            }

            customSerializerStopwatch.Stop();

            Console.WriteLine("XmlSerializer Elapsed Time: {0}", xmlSerializerStopwatch.Elapsed);
            Console.WriteLine("CustomSerializder Elapsed Time: {0}", customSerializerStopwatch.Elapsed);
        }
        public void Benchmark()
        {
            new System.Xml.Serialization.XmlSerializer(typeof(JitPreparation), null, null, null, null);
            CustomSerializer.GetSerializer(typeof(JitPreparation), null, TestXmlSerializerOptions.Empty);

            var containerWithAbstract =
                new ColdStartContainerWithAbstract
                {
                    Id = "a",
                    One =
                        new ColdStartOneWithAbstract
                        {
                            Id = "b",
                            Two = new ColdStartTwoWithAbstract { Id = "c", Value = "abc" }
                        }
                };
            var containerWithInterface =
                new ColdStartContainerWithInterface
                {
                    Id = "a",
                    One =
                        new ColdStartOneWithInterface
                        {
                            Id = "b",
                            Two = new ColdStartTwoWithInterface { Id = "c", Value = "abc" }
                        }
                };

            var xmlSerializerStopwatch = Stopwatch.StartNew();

            var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(ColdStartContainerWithAbstract), null, null, null, null);
            var xmlSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(xmlSerializerStringBuilder))
            {
                using (var writer = new XmlTextWriter(stringWriter))
                {
                    xmlSerializer.Serialize(writer, containerWithAbstract, null);
                }
            }

            using (var stringReader = new StringReader(xmlSerializerStringBuilder.ToString()))
            {
                using (var reader = new XmlTextReader(stringReader))
                {
                    xmlSerializer.Deserialize(reader);
                }
            }

            xmlSerializerStopwatch.Stop();

            ISerializeOptions options = new TestSerializeOptions();

            var customSerializerStopwatch = Stopwatch.StartNew();

            var customSerializer = CustomSerializer.GetSerializer(typeof(ColdStartContainerWithInterface), null, TestXmlSerializerOptions.Empty);
            var customSerializerStringBuilder = new StringBuilder();

            using (var stringWriter = new StringWriter(customSerializerStringBuilder))
            {
                using (var writer = new XSerializerXmlTextWriter(stringWriter, options))
                {
                    customSerializer.SerializeObject(writer, containerWithInterface, new TestSerializeOptions(true));
                }
            }

            using (var stringReader = new StringReader(customSerializerStringBuilder.ToString()))
            {
                using (var xmlReader = new XmlTextReader(stringReader))
                {
                    using (var reader = new XSerializerXmlReader(xmlReader, options.GetEncryptionMechanism(), options.EncryptKey, options.SerializationState))
                    {
                        customSerializer.DeserializeObject(reader, options);
                    }
                }
            }

            customSerializerStopwatch.Stop();

            Console.WriteLine("XmlSerializer Elapsed Time: {0}", xmlSerializerStopwatch.Elapsed);
            Console.WriteLine("CustomSerializer Elapsed Time: {0}", customSerializerStopwatch.Elapsed);
        }