Пример #1
1
        private static void Main(string[] args)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                int threads;
                int iothreads;
                ThreadPool.GetMinThreads(out threads, out iothreads);

                DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(threads));

                ThreadPool.SetMinThreads(32000, 4000);
                ThreadPool.SetMaxThreads(32000, 4000);

                Emulator emulator = new Emulator {Running = true};
                Stopwatch watch = new Stopwatch();
                watch.Start();

                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                for (int j = 0; j < NumberOfBots; j++)
                {
                    string playerName = $"TheGrey{j + 1:D3}";

                    ClientEmulator client = new ClientEmulator(threadPool, emulator, DurationOfConnection,
                        playerName, (int) (DateTime.UtcNow.Ticks - start), endPoint,
                        RanSleepMin, RanSleepMax, RequestChunkRadius);

                    new Thread(o => { client.EmulateClient(); }) {IsBackground = true}.Start();
                    //ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                    Thread.Sleep(TimeBetweenSpawns);
                }

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            Console.WriteLine("Press <Enter> to start emulation...");
            Console.ReadLine();

            ThreadPool.SetMinThreads(1000, 1000);

            Emulator emulator = new Emulator {
                Running = true
            };
            Stopwatch watch = new Stopwatch();

            watch.Start();

            long start = DateTime.UtcNow.Ticks;

            for (int j = 0; j < 200; j++)
            {
                //string playerName = $"{Guid.NewGuid()}";
                string         playerName = $"TheGrey{j + 1:D3}";
                ClientEmulator client     = new ClientEmulator(emulator, 12 * 60 * 1000, playerName, (int)(DateTime.UtcNow.Ticks - start));
                ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                Thread.Sleep(150);
            }

            Console.WriteLine("Press <enter> to stop all clients.");
            Console.ReadLine();
            emulator.Running = false;

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #3
0
		private static void Main(string[] args)
		{
			AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
			Console.WriteLine("Press <Enter> to start emulation...");
			Console.ReadLine();

			ThreadPool.SetMinThreads(1000, 1000);

			Emulator emulator = new Emulator {Running = true};
			Random random = new Random();

			//{
			//	Stopwatch watch = new Stopwatch();
			//	watch.Start();
			//	int i = 0;
			//	while (watch.ElapsedMilliseconds < 300*1000)
			//	{
			//		if (i > 0 && i%10 == 0) Thread.Sleep(10000);

			//		string playerName = string.Format("Player-{0}", (i + 1));
			//		//string playerName = "Player " + Guid.NewGuid();
			//		ClientEmulator client = new ClientEmulator(emulator, random.Next(60, 120)*1000, playerName, i)
			//		{
			//			Random = random
			//		};
			//		ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

			//		Thread.Sleep(500);

			//		i++;
			//	}
			//}

			{
				Stopwatch watch = new Stopwatch();
				watch.Start();
				for (int j = 0; j < 100; j++)
				{
					string playerName = string.Format("Player-{0}", (j + 1));
					ClientEmulator client = new ClientEmulator(emulator, 300*1000, playerName, j)
					{
						Random = random
					};
					ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

					Thread.Sleep(500);
				}
			}

			Thread.Sleep(300000);

			Console.WriteLine("Press <enter> to stop all clients.");

			Console.ReadLine();
			emulator.Running = false;

			Console.WriteLine("Emulation complete. Press <enter> to exit.");
			Console.ReadLine();
		}
Пример #4
0
        private static void Main(string[] args)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                //int threads;
                //int iothreads;

                //ThreadPool.GetMaxThreads(out threads, out iothreads);
                //ThreadPool.SetMaxThreads(threads, 4000);

                //ThreadPool.GetMinThreads(out threads, out iothreads);
                //ThreadPool.SetMinThreads(4000, 4000);

                DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount));

                Emulator emulator = new Emulator {
                    Running = true
                };
                Stopwatch watch = new Stopwatch();
                watch.Start();

                long start = DateTime.UtcNow.Ticks;

                IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                for (int j = 0; j < NumberOfBots; j++)
                {
                    string playerName = $"TheGrey{j + 1:D3}";

                    ClientEmulator client = new ClientEmulator(threadPool, emulator, DurationOfConnection,
                                                               playerName, (int)(DateTime.UtcNow.Ticks - start), endPoint,
                                                               RanSleepMin, RanSleepMax, RequestChunkRadius);

                    new Thread(o => { client.EmulateClient(); })
                    {
                        IsBackground = true
                    }.Start();

                    Thread.Sleep(TimeBetweenSpawns);
                }

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #5
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            Console.WriteLine("Press <Enter> to start emulation...");
            Console.ReadLine();

            ThreadPool.SetMinThreads(1000, 1000);

            Emulator emulator = new Emulator {
                Running = true
            };
            Stopwatch watch = new Stopwatch();

            watch.Start();

            long start = DateTime.UtcNow.Ticks;

            IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

            for (int j = 0; j < NumberOfBots; j++)
            {
                string playerName = $"TheGrey{j + 1:D3}";

                ClientEmulator client = new ClientEmulator(emulator, DurationOfConnection,
                                                           playerName, (int)(DateTime.UtcNow.Ticks - start), endPoint,
                                                           RanSleepMin, RanSleepMax, RequestChunkRadius);

                ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                Thread.Sleep(TimeBetweenSpawns);
            }

            Console.WriteLine("Press <enter> to stop all clients.");
            Console.ReadLine();
            emulator.Running = false;

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #6
0
        private static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.xml"));

            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                //int threads;
                //int iothreads;

                //ThreadPool.GetMaxThreads(out threads, out iothreads);
                //ThreadPool.SetMaxThreads(threads, 4000);

                //ThreadPool.GetMinThreads(out threads, out iothreads);
                //ThreadPool.SetMinThreads(4000, 4000);

                //DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount));
                DedicatedThreadPool threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(4000));

                Emulator emulator = new Emulator {
                    Running = true
                };
                Stopwatch watch = new Stopwatch();
                watch.Start();

                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                var sw = Stopwatch.StartNew();
                for (int j = 0; j < NumberOfBots; j++)
                {
                    string playerName = $"TheGrey{j + 1:D3}";

                    ClientEmulator client = new ClientEmulator(threadPool, emulator, DurationOfConnection,
                                                               playerName, (int)(DateTime.UtcNow.Ticks - start), endPoint,
                                                               RanSleepMin, RanSleepMax, RequestChunkRadius);

                    new Thread(o => { client.EmulateClient(); })
                    {
                        IsBackground = true
                    }.Start();

                    if (ConcurrentSpawn)
                    {
                        emulator.ConcurrentSpawnWaitHandle.Set();
                    }

                    emulator.ConcurrentSpawnWaitHandle.WaitOne();

                    long elapsed = sw.ElapsedMilliseconds;
                    if (elapsed < TimeBetweenSpawns)
                    {
                        Thread.Sleep((int)(TimeBetweenSpawns - elapsed));
                    }

                    sw.Restart();
                }

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #7
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            Console.WriteLine("Press <Enter> to start emulation...");
            Console.ReadLine();

            ThreadPool.SetMinThreads(1000, 1000);

            Emulator emulator = new Emulator {
                Running = true
            };
            Random random = new Random();

            //{
            //	Stopwatch watch = new Stopwatch();
            //	watch.Start();
            //	int i = 0;
            //	while (watch.ElapsedMilliseconds < 300*1000)
            //	{
            //		if (i > 0 && i%10 == 0) Thread.Sleep(10000);

            //		string playerName = string.Format("Player-{0}", (i + 1));
            //		//string playerName = "Player " + Guid.NewGuid();
            //		ClientEmulator client = new ClientEmulator(emulator, random.Next(60, 120)*1000, playerName, i)
            //		{
            //			Random = random
            //		};
            //		ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

            //		Thread.Sleep(500);

            //		i++;
            //	}
            //}

            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                for (int j = 0; j < 100; j++)
                {
                    string         playerName = string.Format("Player-{0}", (j + 1));
                    ClientEmulator client     = new ClientEmulator(emulator, 300 * 1000, playerName, j)
                    {
                        Random = random
                    };
                    ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                    Thread.Sleep(500);
                }
            }

            Thread.Sleep(300000);

            Console.WriteLine("Press <enter> to stop all clients.");

            Console.ReadLine();
            emulator.Running = false;

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #8
0
        /// <summary>
        /// </summary>
        /// <param name="numberOfBots">The number of bots to spawn.</param>
        /// <param name="durationOfConnection">How long (in seconds) should each individual bots stay connected.</param>
        /// <param name="concurrentSpawn">Should the emulator spawn bots in parallel.</param>
        /// <param name="batchSize">If parallel spawn, how many in each batch.</param>
        /// <param name="chunkRadius">The chunk radius the bots will request. Server may override.</param>
        /// <param name="processorAffinity">Processor affinity mask represented as an integer.</param>
        private static void Main(int numberOfBots = 500, int durationOfConnection = 900, bool concurrentSpawn = true, int batchSize = 5, int chunkRadius = 5, int processorAffinity = 0)
        {
            NumberOfBots         = numberOfBots;
            DurationOfConnection = TimeSpan.FromSeconds(durationOfConnection);
            ConcurrentSpawn      = concurrentSpawn;
            ConcurrentBatchSize  = batchSize;
            RequestChunkRadius   = chunkRadius;

            var currentProcess = Process.GetCurrentProcess();

            currentProcess.ProcessorAffinity = processorAffinity <= 0 ? currentProcess.ProcessorAffinity : (IntPtr)processorAffinity;

            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "log4net.xml")));

            Console.ResetColor();
            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(MiNetServer.MiNET);
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;

            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
                Console.WriteLine("Press <Enter> to start emulation...");
                Console.ReadLine();

                var threadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount));

                var emulator = new Emulator {
                    Running = true
                };
                long start = DateTime.UtcNow.Ticks;

                //IPEndPoint endPoint = new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132);
                var endPoint = new IPEndPoint(IPAddress.Loopback, 19132);

                Task.Run(() =>
                {
                    var sw = Stopwatch.StartNew();
                    for (int j = 0; j < NumberOfBots; j++)
                    {
                        string playerName = $"TheGrey{j + 1:D3}";

                        var client = new ClientEmulator(threadPool,
                                                        emulator,
                                                        DurationOfConnection,
                                                        playerName,
                                                        (int)(DateTime.UtcNow.Ticks - start),
                                                        endPoint,
                                                        RanSleepMin,
                                                        RanSleepMax,
                                                        RequestChunkRadius);

                        new Thread(o => { client.EmulateClient(); })
                        {
                            IsBackground = true
                        }.Start();

                        if (ConcurrentSpawn)
                        {
                            if (j % ConcurrentBatchSize == 0 && j != 0)
                            {
                                for (int i = 0; i < ConcurrentBatchSize; i++)
                                {
                                    emulator.ConcurrentSpawnWaitHandle.WaitOne(TimeSpan.FromMilliseconds(1000));
                                }
                            }

                            continue;
                        }

                        emulator.ConcurrentSpawnWaitHandle.WaitOne();

                        long elapsed = sw.ElapsedMilliseconds;
                        if (elapsed < TimeBetweenSpawns)
                        {
                            Thread.Sleep((int)(TimeBetweenSpawns - elapsed));
                        }

                        sw.Restart();
                    }
                });

                Console.WriteLine("Press <enter> to stop all clients.");
                Console.ReadLine();
                emulator.Running = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.ResetColor();
            }

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }
Пример #9
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Press <Enter> to start emulation...");
            Console.ReadLine();

            ThreadPool.SetMinThreads(1000, 1000);

            Emulator emulator = new Emulator {Running = true};
            Random random = new Random();

            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                int i = 0;
                while (watch.ElapsedMilliseconds < 300*1000)
                {
                    if (i > 0 && i%10 == 0) Thread.Sleep(10000);

                    string playerName = string.Format("Player-{0}", (i + 1));
                    //string playerName = "Player " + Guid.NewGuid();
                    ClientEmulator client = new ClientEmulator(emulator, random.Next(60, 120)*1000, playerName, i)
                    {
                        Random = random
                    };
                    ThreadPool.QueueUserWorkItem(delegate { client.EmulateClient(); });

                    Thread.Sleep(200);

                    i++;
                }
            }

            Console.WriteLine("Press <enter> to stop all clients.");

            Console.ReadLine();
            emulator.Running = false;

            Console.WriteLine("Emulation complete. Press <enter> to exit.");
            Console.ReadLine();
        }