FillDummyData() public method

public FillDummyData ( ) : void
return void
        public void RunExpt1()
        {
            // Quick copy-cat experiment trying to DER encode the InheritedEntity object
            // but by hand here
            var e = new InheritedEntity();
            e.FillDummyData();

            const int iterations = 1000;
            var asn1DerBytes= new byte[0];

            var sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < iterations; i++)
                asn1DerBytes = SerializeAsn1(e);
            sw.Stop();

            // x2 since we're only serializing here, (big) assumption
            // that a ser->deser route will be double, but ok for coarse measures
            var avgMs = sw.Elapsed.TotalMilliseconds*2/iterations;

            File.WriteAllBytes("Asn1Expt.der", asn1DerBytes);
            Console.WriteLine("Serialized via ASN.1 DER encoding to {0} bytes in {1,4:n4} ms: {2}",
                asn1DerBytes.Length,
                avgMs,
                BitConverter.ToString(asn1DerBytes));
        }
        public void RunExpt1()
        {
            // Prepare input entity, we reuse existing init code
            // and just Inject (via Value Injecter library)
            var origMsg = new InheritedEntity();
            origMsg.FillDummyData();
            var origMsgJson = JsonConvert.SerializeObject(origMsg);
            Console.WriteLine("Original object is {0}", origMsgJson);

            // Serialization
            var tmsg = new InheritedEntityThrift();
            tmsg.InjectFrom(origMsg);
            var ms = new MemoryStream();
            var tproto = new TCompactProtocol(new TStreamTransport(ms, ms));
            tmsg.Write(tproto);
            var tbytes = ms.ToArray();

            Console.WriteLine("Serialized to {0} bytes: {1}", tbytes.Length, BitConverter.ToString(tbytes));

            // Deserialization
            var ms2 = new MemoryStream(tbytes);
            var tproto2 = new TCompactProtocol(new TStreamTransport(ms2, ms2));
            var regenTMsg = new InheritedEntityThrift();
            regenTMsg.Read(tproto2);
            var regenMsg = new InheritedEntity();
            regenMsg.InjectFrom(regenTMsg);

            var regenMsgJson = JsonConvert.SerializeObject(regenMsg);
            Console.WriteLine("Regenerated object is {0}", regenMsgJson);
        }
Example #3
0
        static void RunTests()
        {
            // Pick an entity type
            //var originalObject = new SimpleEntity();
            var originalObject = new InheritedEntity();
            originalObject.FillDummyData();
            Test = new Test<InheritedEntity>();
            //Test = new Test<SimpleEntity>();

            Results = Test.RunTests(originalObject, NumOfObjects);
        }
Example #4
0
        private void AvroMsftToAvro()
        {
            // avro-msft ser => avro deser

            var e = new InheritedEntity();
            e.FillDummyData();

            // Avro MSFT serialize
            var eBytes = SerializeAvroMsft(e);

            // Avro-Apache deserialize
            var eCodeGenEntity = DeserializeAvro(eBytes);
            var eAppEntityRegen = new InheritedEntity();
            eAppEntityRegen.InjectFrom(eCodeGenEntity);

            // Compare the object (in JSON, easiest to do so)
            var eJson = JsonConvert.SerializeObject(e);
            var eRegenJson = JsonConvert.SerializeObject(eAppEntityRegen);

            Console.Write("avro-msft ser => avro deser ");
            if (eJson != eRegenJson)
                Console.WriteLine("FAILED !!!");
            else
                Console.WriteLine("passed");
        }