Beispiel #1
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();
            }
        }
        public async void SoakRunAsync(int threadCount)
        {
            var driver = GraphDatabase.Driver(ServerEndPoint, AuthToken, new Config
            {
                DriverMetricsEnabled         = true,
                ConnectionTimeout            = Config.InfiniteInterval,
                MaxConnectionPoolSize        = 500,
                EncryptionLevel              = EncryptionLevel.Encrypted,
                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.RunAsync());
            }
            await Task.WhenAll(tasks);

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

            Output.WriteLine(m.ToString());
            Output.WriteLine(m.AcquisitionTimeHistogram.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));

            await driver.CloseAsync();
        }