Esempio n. 1
0
        public void AReadPBAndDTOAndValidate()
        {
            DateTime start   = DateTime.Now;
            DateTime current = start;
            TimeSpan elapsed;

            using FileStream input = File.OpenRead(ProtobufFile);
            Int32    i        = 0;
            PBReader pbReader = new PBReader(input);

            NativeMethods.PreventSleep();
            foreach (IComponent component in this.ReadConcepts())
            {
                PBTinkarMsg pbMsg = pbReader.Read();
                IComponent  dto   = ConvertPBToDTO.Convert(pbMsg);
                Assert.True(component.CompareTo(dto) == 0);
                if ((i % BlockSize) == 0)
                {
                    elapsed = DateTime.Now - current;
                    current = DateTime.Now;
                    float itemsPerSec = (float)BlockSize / (float)elapsed.TotalSeconds;
                    Trace.WriteLine($"{i} - Read time {elapsed.TotalSeconds} / {itemsPerSec.ToString("F2")}");
                    GC.Collect(2, GCCollectionMode.Forced);
                }
                i += 1;
            }
            Assert.True(pbReader.Read() == null);

            elapsed = DateTime.Now - start;
            NativeMethods.AllowSleep();
            Trace.WriteLine($"AProtobufReadConcepts time {elapsed}");
        }
Esempio n. 2
0
        public void AConvertAndVerifyAllConcepts()
        {
            NativeMethods.PreventSleep();
            DateTime start = DateTime.Now;
            Int32    i     = 0;

            foreach (IComponent component in this.ReadConcepts())
            {
                PBTinkarMsg pb = ConvertDTOToPB.Convert(component);
                if (pb != null)
                {
                    IComponent dto = ConvertPBToDTO.Convert(pb);
                    Assert.True(component.CompareTo(dto) == 0);
                }
                i += 1;
            }
            NativeMethods.AllowSleep();
            TimeSpan elapsed = DateTime.Now - start;

            Trace.WriteLine($"AConvertAndVerifyAllConcepts time {elapsed}");
        }