Exemplo n.º 1
0
        public void Invoke()
        {
            var graph = DataBlock.Filled();

            var watch = new Stopwatch();

            watch.Start();
            Console.WriteLine("Initializing ProtoBuf.NET serialization test...");
            var protobuf = new ProtocolBuffer.ProtocolBufferBinaryConverter <DataBlock>();
            var length   = protobuf.Convert(graph).Length;

            Console.WriteLine("Initialization time: " + watch.Elapsed);
            Console.WriteLine("MinSize of data: " + length);
            watch.Restart();

            for (var i = 0; i < 10000; i++)
            {
                protobuf.Convert(graph);
            }

            Console.WriteLine("Serialization time: " + watch.Elapsed);
            watch.Restart();

            Parallel.For(0, 10000, new ParallelOptions {
                MaxDegreeOfParallelism = 4
            }, (idx) => {
                protobuf.Convert(graph);
            });

            Console.WriteLine("Parallel serialization time: " + watch.Elapsed);

            Console.WriteLine("Enigma serialization test completed");
        }
 public void ProtoBufTest()
 {
     var converter = new ProtocolBuffer.ProtocolBufferBinaryConverter<DataBlock>();
     var bytes = converter.Convert(DataBlock.Filled());
     Assert.IsNotNull(bytes);
     Assert.IsTrue(bytes.Length > 0);
     var hex = "0x" + string.Join("", bytes.Select(b => b.ToString("X")));
     Assert.IsNotNull(hex);
 }
Exemplo n.º 3
0
        public void Invoke()
        {
            var graph = DataBlock.Filled();

            var watch = new Stopwatch();
            watch.Start();
            Console.WriteLine("Initializing ProtoBuf.NET serialization test...");
            var protobuf = new ProtocolBuffer.ProtocolBufferBinaryConverter<DataBlock>();
            var length = protobuf.Convert(graph).Length;

            var initializationTime = watch.Elapsed;

            for (var i = 0; i < 10000; i++) {
                protobuf.Convert(graph);
            }

            var serializationTime = watch.Elapsed.Subtract(initializationTime);

            Console.WriteLine("Enigma serialization test completed");
            Console.WriteLine("Size of data: " + length);
            Console.WriteLine("Initialization time: " + initializationTime);
            Console.WriteLine("Serialization time: " + serializationTime);
        }