コード例 #1
0
        public void Test1()
        {
            MemoryPoolTest.TestMemoryLeak();
            DebugStopwatch sw = new DebugStopwatch();

            for (int max = 10; max < 10000; max *= 2)
            {
                Action add1 = () =>
                {
                    SortedList <int, int> list = new SortedList <int, int>();
                    for (int x = 0; x < max; x++)
                    {
                        list.Add(x, x);
                    }
                };

                Action add2 = () =>
                {
                    List <int> keys   = new List <int>(max);
                    List <int> values = new List <int>(max);

                    for (int x = 0; x < max; x++)
                    {
                        keys.Add(x);
                        values.Add(x);
                    }

                    var sl = SortedListConstructor.Create(keys, values);
                };

                //var makeList = new SortedListConstructorUnsafe<int, int>();
                //Action add3 = () =>
                //{
                //    List<int> keys = new List<int>(max);
                //    List<int> values = new List<int>(max);

                //    for (int x = 0; x < max; x++)
                //    {
                //        keys.Add(x);
                //        values.Add(x);
                //    }

                //    var sl = makeList.Create(keys, values);
                //    //var sl = SortedListConstructor.CreateUnsafe(keys, values);

                //};
                System.Console.WriteLine("Old Method " + max + " " + sw.TimeEvent(add1) * 1000000);
                System.Console.WriteLine("New Method " + max + " " + sw.TimeEvent(add2) * 1000000);
                //Console.WriteLine("Unsafe Method " + max + " " + sw.TimeEvent(add3) * 1000000);
                MemoryPoolTest.TestMemoryLeak();
            }
        }
コード例 #2
0
        public void TestBlocksPerSecond()
        {
            //UnmanagedMemory.Memory.UseLargePages = true;
            DebugStopwatch sw = new DebugStopwatch();

            using (MemoryPoolStream ms = new MemoryPoolStream())
            {
                using (BinaryStreamIoSessionBase io = ms.CreateIoSession())
                {
                    BlockArguments args = new BlockArguments();
                    args.Position  = ms.BlockSize * 2000L - 1;
                    args.IsWriting = true;

                    io.GetBlock(args);

                    double sec = sw.TimeEvent(() =>
                    {
                        for (int y = 0; y < 100; y++)
                        {
                            for (int x = 0; x < 2000; x++)
                            {
                                args.Position = (long)x * ms.BlockSize;
                                io.GetBlock(args);
                            }
                        }
                    });

                    System.Console.WriteLine("Get Blocks: " + (200000 / sec / 1000000).ToString("0.00 Million Per Second"));
                }
            }
        }
コード例 #3
0
        public void BenchmarkTwoFiles()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max = 1000000;
            ArchiveList <HistorianKey, HistorianValue> list = new ArchiveList <HistorianKey, HistorianValue>(null);
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();
            SortedTreeTable <HistorianKey, HistorianValue> table1 = CreateTable();
            SortedTreeTable <HistorianKey, HistorianValue> table2 = CreateTable();

            AddData(table1, 100, 100, Max / 2);
            AddData(table2, 101, 100, Max / 2);
            using (ArchiveListEditor <HistorianKey, HistorianValue> editor = list.AcquireEditLock())
            {
                editor.Add(table1);
                editor.Add(table2);
            }

            SequentialReaderStream <HistorianKey, HistorianValue> sequencer = new SequentialReaderStream <HistorianKey, HistorianValue>(list);

            DebugStopwatch sw = new DebugStopwatch();

            double sec = sw.TimeEvent(() =>
            {
                SequentialReaderStream <HistorianKey, HistorianValue> scanner = sequencer;
                while (scanner.Read(key, value))
                {
                }
            });

            System.Console.WriteLine(Max / sec / 1000000);
            list.Dispose();
            MemoryPoolTest.TestMemoryLeak();
        }
コード例 #4
0
        public void BenchmarkRawFile()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max = 1000000;

            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            SortedTreeTable <HistorianKey, HistorianValue> master = CreateTable();

            AddData(master, 100, 100, Max);


            DebugStopwatch sw = new DebugStopwatch();

            using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> masterRead = master.BeginRead())
            {
                double sec = sw.TimeEvent(() =>
                {
                    SortedTreeScannerBase <HistorianKey, HistorianValue> scanner = masterRead.GetTreeScanner();
                    scanner.SeekToStart();
                    while (scanner.Read(key, value))
                    {
                    }
                });
                System.Console.WriteLine(Max / sec / 1000000);
            }
            master.Dispose();
            MemoryPoolTest.TestMemoryLeak();
        }
コード例 #5
0
        public void RefreshSpeedTest()
        {
            ST.Reset();

            DebugStopwatch sw = new DebugStopwatch();
            double time = sw.TimeEvent(RefreshSpeed);
            Console.WriteLine(time.ToString() + " seconds to on average");

            Console.WriteLine(ST.GetResultsPercent());
        }
コード例 #6
0
        public void RefreshSpeedTest()
        {
            ST.Reset();

            DebugStopwatch sw   = new DebugStopwatch();
            double         time = sw.TimeEvent(RefreshSpeed);

            Console.WriteLine(time.ToString() + " seconds to on average");

            Console.WriteLine(ST.GetResultsPercent());
        }
コード例 #7
0
ファイル: Srp_Test.cs プロジェクト: yuwenpeng/openHistorian
        public void TestDHKeyExchangeTime()
        {
            var c = SrpConstants.Lookup(SrpStrength.Bits1024);

            c.g.ModPow(c.N, c.N);

            DebugStopwatch sw   = new DebugStopwatch();
            var            time = sw.TimeEvent(() => Hash <Sha1Digest> .Compute(c.Nb));

            System.Console.WriteLine(time);
        }
コード例 #8
0
        public void BenchmarkRealisticSamples()
        {
            MemoryPoolTest.TestMemoryLeak();
            const int Max       = 1000000;
            const int FileCount = 1000;
            ArchiveList <HistorianKey, HistorianValue> list = new ArchiveList <HistorianKey, HistorianValue>(null);
            DateTime       start = DateTime.Now.Date;
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            for (int x = 0; x < FileCount; x++)
            {
                SortedTreeTable <HistorianKey, HistorianValue> table1 = CreateTable();
                AddData(table1, start.AddMinutes(2 * x), new TimeSpan(TimeSpan.TicksPerSecond), 60, 100, 1, Max / 60 / FileCount);
                using (ArchiveListEditor <HistorianKey, HistorianValue> editor = list.AcquireEditLock())
                {
                    editor.Add(table1);
                }
            }

            SeekFilterBase <HistorianKey> filter = TimestampSeekFilter.CreateFromIntervalData <HistorianKey>(start, start.AddMinutes(2 * FileCount), new TimeSpan(TimeSpan.TicksPerSecond * 2), new TimeSpan(TimeSpan.TicksPerMillisecond));
            SequentialReaderStream <HistorianKey, HistorianValue> sequencer = new SequentialReaderStream <HistorianKey, HistorianValue>(list, null, filter);

            DebugStopwatch sw  = new DebugStopwatch();
            int            xi  = 0;
            double         sec = sw.TimeEvent(() =>
            {
                SequentialReaderStream <HistorianKey, HistorianValue> scanner = sequencer;
                while (scanner.Read(key, value))
                {
                    xi++;
                }
            });

            System.Console.WriteLine(Max / sec / 1000000);
            //TreeKeyMethodsBase<HistorianKey>.WriteToConsole();
            //TreeValueMethodsBase<HistorianValue>.WriteToConsole();

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
            list.Dispose();

            MemoryPoolTest.TestMemoryLeak();
        }
コード例 #9
0
        public void Test()
        {
            Console.WriteLine(Environment.StackTrace);

            RunMethod();
            DebugStopwatch sw   = new DebugStopwatch();
            double         time = sw.TimeEvent(() =>
            {
                for (int x = 0; x < 1000; x++)
                {
                    RunMethod3();
                }
            });

            Console.WriteLine(1000 / time);
        }
コード例 #10
0
        public void TestReadData()
        {
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            var settings = new HistorianServerDatabaseConfig("PPA", @"c:\temp\Scada\", true);

            using (HistorianServer server = new HistorianServer(settings))
            {
                double count = 0;

                DebugStopwatch sw   = new DebugStopwatch();
                double         time = sw.TimeEvent(() =>
                {
                    count = 0;
                    using (HistorianClient client = new HistorianClient("127.0.0.1", 12345))
                        using (ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>(String.Empty))
                        {
                            //IHistorianDatabase<HistorianKey, HistorianValue> database = server.GetDefaultDatabase();//.GetDatabase();
                            //TreeStream<HistorianKey, HistorianValue> stream = reader.Read(0, ulong.MaxValue, new ulong[] { 2 });
                            TreeStream <HistorianKey, HistorianValue> stream = database.Read(0, ulong.MaxValue);
                            while (stream.Read(key, value))
                            {
                                count++;
                            }
                        }
                });

                Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");
            }

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
            //for (int x = 0; x < 15; x++)
            //{
            //    Console.WriteLine(BinaryStreamBase.CallMethods[x] + "\t" + ((BinaryStreamBase.Method)(x)).ToString());
            //}
        }
コード例 #11
0
        public void BenchmarkWriteSpeed()
        {
            DebugStopwatch sw = new DebugStopwatch();

            double time;
            double count = 0;

            using (SortedTreeFile file = SortedTreeFile.CreateInMemory())
            {
                var            table = file.OpenOrCreateTable <HistorianKey, HistorianValue>(HistorianFileEncodingDefinition.TypeGuid);
                HistorianKey   key   = new HistorianKey();
                HistorianValue value = new HistorianValue();

                time = sw.TimeEvent(() =>
                {
                    //TreeKeyMethodsBase<HistorianKey>.ClearStats();
                    //TreeValueMethodsBase<HistorianKey>.ClearStats();
                    count = 0;
                    using (var scan = table.BeginEdit())
                    {
                        for (uint x = 0; x < 10000000; x++)
                        {
                            key.PointID = x;
                            scan.AddPoint(key, value);
                            count++;
                        }
                        scan.Rollback();
                    }
                });
            }

            Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
        }
コード例 #12
0
        public void TestReadDataFromArchive()
        {
            DebugStopwatch sw    = new DebugStopwatch();
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            string path = Directory.GetFiles(@"c:\temp\Scada\", "*.d2")[0];
            double time;
            double count = 0;

            using (SortedTreeFile file = SortedTreeFile.OpenFile(path, true))
            {
                var table = file.OpenTable <HistorianKey, HistorianValue>();

                time = sw.TimeEvent(() =>
                {
                    count = 0;
                    using (var scan = table.BeginRead())
                    {
                        var t = scan.GetTreeScanner();
                        t.SeekToStart();
                        while (t.Read(key, value))
                        {
                            count++;
                        }
                    }
                });
            }
            Console.WriteLine((count / 1000000 / time).ToString() + " Million PPS");

            //Console.WriteLine("KeyMethodsBase calls");
            //for (int x = 0; x < 23; x++)
            //{
            //    Console.WriteLine(TreeKeyMethodsBase<HistorianKey>.CallMethods[x] + "\t" + ((TreeKeyMethodsBase<HistorianKey>.Method)(x)).ToString());
            //}
            //Console.WriteLine("ValueMethodsBase calls");
            //for (int x = 0; x < 5; x++)
            //{
            //    Console.WriteLine(TreeValueMethodsBase<HistorianValue>.CallMethods[x] + "\t" + ((TreeValueMethodsBase<HistorianValue>.Method)(x)).ToString());
            //}
        }