コード例 #1
0
        public async Task RoutingDriverStressTestAsync(int queryCount)
        {
            const int taskCount = 5;
            var       startTime = DateTime.Now;

            Output.WriteLine($"[{startTime:HH:mm:ss.ffffff}] Started");

            var workItem = new SoakRunWorkItem(_driver, _metrics, Output);

            var terminationTask = ConnectionTerminatorAsync();
            var tasks           = new List <Task>();

            for (var i = 0; i < taskCount; i++)
            {
                tasks.Add(workItem.RunWithRetriesAsync(queryCount / taskCount));
            }

            await Task.WhenAll(tasks);

            _cancellationTokenSource.Cancel();
            await terminationTask;

            var endTime = DateTime.Now;

            Output.WriteLine($"[{endTime:HH:mm:ss.ffffff}] Finished");
            Output.WriteLine($"Total time spent: {endTime - startTime}");

            PrintStatistics();

            await _driver.CloseAsync();
        }
コード例 #2
0
        public async void SoakRunAsync(int threadCount)
        {
            var driver = GraphDatabase.Driver(RoutingServer, AuthToken, new Config
            {
                MetricsFactory               = new DefaultMetricsFactory(),
                ConnectionTimeout            = Config.InfiniteInterval,
                EncryptionLevel              = EncryptionLevel.Encrypted,
                MaxConnectionPoolSize        = 100,
                ConnectionAcquisitionTimeout = TimeSpan.FromMinutes(5)
            });

            try
            {
                var startTime = DateTime.Now;
                Output.WriteLine($"[{startTime:HH:mm:ss.ffffff}] Started");

                var metrics  = ((Internal.Driver)driver).GetMetrics();
                var workItem = new SoakRunWorkItem(driver, metrics, Output);

                var tasks = new List <Task>();
                for (var i = 0; i < threadCount; i++)
                {
                    tasks.Add(workItem.RunAsync());
                }

                await Task.WhenAll(tasks);

                var poolMetrics = metrics.ConnectionPoolMetrics;
                Output.WriteLine(poolMetrics.ToContentString());
                var endTime = DateTime.Now;
                Output.WriteLine($"[{endTime:HH:mm:ss.ffffff}] Finished");
                Output.WriteLine($"Total time spent: {endTime - startTime}");

                foreach (var value in poolMetrics)
                {
                    var st = value.Value;

                    st.Creating.Should().Be(0);
                    st.Closing.Should().Be(0);
                    st.InUse.Should().Be(0);
                    st.Idle.Should().Be((int)(st.Created - st.Closed + st.FailedToCreate));
                }
            }
            finally
            {
                await driver.CloseAsync();
            }
        }
コード例 #3
0
        public void SoakRunTests(int threadCount)
        {
            var driver = GraphDatabase.Driver(RoutingServer, AuthToken, new Config
            {
                DriverMetricsEnabled         = true,
                ConnectionTimeout            = Config.InfiniteInterval,
                EncryptionLevel              = EncryptionLevel.Encrypted,
                MaxIdleConnectionPoolSize    = 20,
                MaxConnectionPoolSize        = 50,
                ConnectionAcquisitionTimeout = TimeSpan.FromMinutes(2)
            });
            var startTime = DateTime.Now;

            Output.WriteLine($"[{startTime:HH:mm:ss.ffffff}] Started");

            var metrics  = ((Internal.Driver)driver).GetMetrics();
            var workItem = new SoakRunWorkItem(driver, metrics, Output);

            var tasks = new List <Task>();

            for (var i = 0; i < threadCount; i++)
            {
                tasks.Add(workItem.Run());
            }
            Task.WaitAll(tasks.ToArray());

            var poolMetrics = metrics.ConnectionPoolMetrics;

            Output.WriteLine(poolMetrics.ToContentString());
            var endTime = DateTime.Now;

            Output.WriteLine($"[{endTime:HH:mm:ss.ffffff}] Finished");
            Output.WriteLine($"Total time spent: {endTime - startTime}");

            foreach (var value in poolMetrics)
            {
                var st = value.Value;

                st.Creating.Should().Be(0);
                st.Closing.Should().Be(0);
                st.InUse.Should().Be(0);
                st.Idle.Should().Be((int)(st.Created - st.Closed));
            }

            driver.Close();
        }
コード例 #4
0
//        [InlineData(50000)] leave this to a long dedicated build
        public void SoakRun(int threadCount)
        {
            var driver = GraphDatabase.Driver(ServerEndPoint, AuthToken, new Config
            {
                DriverMetricsEnabled = true,
                ConnectionTimeout    = Config.InfiniteInterval,
                EncryptionLevel      = EncryptionLevel.Encrypted
            });


            var startTime = DateTime.Now;

            Output.WriteLine($"[{startTime:HH:mm:ss.ffffff}] Started");

            var metrics  = ((Internal.Driver)driver).GetMetrics();
            var workItem = new SoakRunWorkItem(driver, metrics, Output);

            var tasks = new List <Task>();

            for (var i = 0; i < threadCount; i++)
            {
                tasks.Add(workItem.Run());
            }
            Task.WaitAll(tasks.ToArray());

            var m  = metrics.ConnectionPoolMetrics.Single().Value;
            var cm = metrics.ConnectionMetrics.Single().Value;

            Output.WriteLine(m.ToString());
            Output.WriteLine(m.AcquisitionTimeHistogram.ToString());
            Output.WriteLine(cm.ConnectionTimeHistogram.ToString());
            Output.WriteLine(cm.InUseTimeHistogram.ToString());

            var endTime = DateTime.Now;

            Output.WriteLine($"[{endTime:HH:mm:ss.ffffff}] Finished");
            Output.WriteLine($"Total time spent: {endTime - startTime}");

            m.Creating.Should().Be(0);
            m.Closing.Should().Be(0);
            m.InUse.Should().Be(0);
            m.Idle.Should().Be((int)(m.Created - m.Closed));

            driver.Close();
        }
コード例 #5
0
//        [InlineData(50000)] leave this to a long dedicated build
        public void SoakRun(int threadCount)
        {
            var driver = GraphDatabase.Driver(ServerEndPoint, AuthToken, new Config
            {
                MetricsFactory        = new DefaultMetricsFactory(),
                ConnectionTimeout     = Config.InfiniteInterval,
                EncryptionLevel       = EncryptionLevel.Encrypted,
                MaxConnectionPoolSize = 100
            });


            var startTime = DateTime.Now;

            Output.WriteLine($"[{startTime:HH:mm:ss.ffffff}] Started");

            var metrics  = ((Internal.Driver)driver).GetMetrics();
            var workItem = new SoakRunWorkItem(driver, metrics, Output);

            Parallel.For(0, threadCount, workItem.Run);

            var m  = metrics.ConnectionPoolMetrics.Single().Value;
            var cm = metrics.ConnectionMetrics.Single().Value;

            Output.WriteLine(m.ToString());
            Output.WriteLine(m.AcquisitionTimeHistogram.ToString());
            Output.WriteLine(cm.ConnectionTimeHistogram.ToString());
            Output.WriteLine(cm.InUseTimeHistogram.ToString());

            var endTime = DateTime.Now;

            Output.WriteLine($"[{endTime:HH:mm:ss.ffffff}] Finished");
            Output.WriteLine($"Total time spent: {endTime - startTime}");

            m.Creating.Should().Be(0);
            m.Closing.Should().Be(0);
            m.InUse.Should().Be(0);
            m.Idle.Should().Be((int)(m.Created - m.Closed + m.FailedToCreate));

            driver.Close();
        }