Esempio n. 1
0
        /// <summary>
        /// Run program.
        /// </summary>
        /// <param name="capacity"></param>
        /// <param name="fillCount"></param>
        /// <param name="testType"></param>
        /// <param name="bufferType"></param>
        static void Run(int capacity, int fillCount, TestType testType, BufferType bufferType)
        {
            // Display program execution options before starting.
            Console.WriteLine("[{0}] pi capacity={1}", DateTime.Now.ToFileTime(), capacity);
            Console.WriteLine("[{0}] pi fill count={1}", DateTime.Now.ToFileTime(), fillCount);
            Console.WriteLine("[{0}] pi test type={1}", DateTime.Now.ToFileTime(), testType);
            Console.WriteLine("[{0}] pi buffer type={1}", DateTime.Now.ToFileTime(), bufferType);
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);

            // Create a stream test instance.
            IStreamTest streamTest = CreateTest(testType, bufferType, capacity);

            foreach (string name in streamTest.GeneratorNames)
            {
                Console.WriteLine("[{0}] gr generator={1}", DateTime.Now.ToFileTime(), name);
            }

            // Run stream test (due to the reliance of generic tipes it is pushed down).
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);
            streamTest.Run(fillCount);
            Console.WriteLine("[{0}] pm {1}kb", DateTime.Now.ToFileTime(), GC.GetTotalMemory(true) / 1024);
        }
Esempio n. 2
0
        public SerializerLimit ExecuteLargePropertyTest(IStreamTest test, ISerializerStream serializerStream)
        {
            for(int size = DataGenerationStepInBytes * 2; size < 1024 * 1024 * MaxPropertySizeInMB; size+=DataGenerationStepInBytes)
            {
                Console.Write($"{test.TestName}->{serializerStream.Name}, size={size.Bytes()}...");
                var limit = test.Execute(serializerStream,SinglePropertyData[size],size);
                if (limit == null)
                    Console.WriteLine("succeeded");
                else
                {
                    Console.WriteLine("failed.");
                    Console.WriteLine("Reason -> " + limit.FailureException.GetType().FullName);
                    Console.WriteLine("Starting looking for exact limit...");
                    const int megabyteInBytes = 1024 * 1024;
                    for(int exactSize = size - megabyteInBytes; exactSize >= (size - DataGenerationStepInBytes); exactSize-= megabyteInBytes)
                    {
                        Console.Write($"Checking {exactSize.Bytes()}...");
                        limit = test.Execute(serializerStream, new SinglePropertyObject
                        {
                            Bytes = Data.Take(exactSize)
                        }, exactSize);
                        if (limit != null)
                            Console.WriteLine("failed");
                        else
                        {
                            Console.WriteLine("succeeded!");
                            Console.WriteLine($"Maximum workable large property for the serializer can be {exactSize.Bytes().ToString("#.##")}");
                            return limit;
                        }
                    }
                    return limit;
                }                
            }

            return null;
        }