Example #1
0
        /// <summary>
        /// Prepare the server and clients for the benchmark.
        /// Starts all instances and connects the clients to the server.
        /// </summary>
        /// <param name="networkBenchmark">Library to use for the benchmark</param>
        public static void PrepareBenchmark(INetworkBenchmark networkBenchmark)
        {
            Utilities.WriteVerbose("-> Prepare Benchmark.");
            Config.PrepareForNewBenchmark();
            networkBenchmark.Initialize(Config, BenchmarkStatistics);
            Utilities.WriteVerbose(".");

            if (Config.IsRunServer())
            {
                var serverTask = networkBenchmark.StartServer();
                serverTask.Wait();
            }

            if (Config.IsRunClients())
            {
                var clientTask = networkBenchmark.StartClients();
                clientTask.Wait();
            }

            Utilities.WriteVerbose(".");

            if (Config.IsRunClients())
            {
                networkBenchmark.ConnectClients().Wait();
            }

            Utilities.WriteVerboseLine(" Done");
        }