public void Run() { mRunning = true; #region WriteDataSet WriteDataSet(); if (System.Threading.ThreadPool.SetMinThreads(300, 300)) { System.Console.WriteLine("Set minimum was successful"); } System.Threading.Thread.Sleep(5000); #endregion #region TimeSpan Test using (outputfile = new System.IO.StreamWriter(Path + "\\timespan_read_test.txt")) { outputfile.WriteLine("Database: " + Program.Database + "\t MaxTimeSpan: " + maxtimespan + "\t Iterations: " + timespaniterations + "\t WriteFrequency: " + writefrequency); outputfile.WriteLine("Timespan\tDuration(ms)"); //TimepanRead-TestCase System.Console.WriteLine("Start TimepanRead-TestCase"); TimeSpan timespanTS = TimeSpan.Parse(timespaninitvalue); TimeSpan maxtimespanTS = TimeSpan.Parse(maxtimespan); telemetry = new Telemetry(Program.VmName, Path, (int)timespanTS.TotalMinutes, adapter); telemetry.SetID("timespan"); telemetry.InitTelemetryCollection("timespan"); while (mRunning) { for (int i = 0; i < timespaniterations; i++) { PrepareReadOne(timespanTS); var sw = System.Diagnostics.Stopwatch.StartNew(); ReadOne(timespanTS); sw.Stop(); double elap = sw.Elapsed.TotalMilliseconds; string logtext = "Timespan: " + timespanTS + " Duration: " + elap; System.Console.WriteLine(logtext); try { outputfile.WriteLine(timespanTS + "\t" + elap); } catch (System.ObjectDisposedException) { } } telemetry.CollectVariableRunTelemetry((int)timespanTS.TotalMinutes); timespanTS += TimeSpan.Parse(timespaninc); if (timespanTS > maxtimespanTS) { break; } try { outputfile.WriteLine("New TimeSpan: " + timespanTS + "\t"); } catch (System.ObjectDisposedException) { } } telemetry.CloseVMConnection(); } #endregion #region Variable Test using (outputfile = new System.IO.StreamWriter(Path + "\\variable_read_test.txt")) { outputfile.WriteLine("Database: " + Program.Database + "\t MaxVariables: " + maxvariables + "\t Iterations: " + variableiterations + "\t Timespan: " + variabletimespan + "\t WriteFrequency: " + writefrequency); outputfile.WriteLine("Variables\tDuration(ms)"); //VariableRead-TestCase System.Console.WriteLine("Start VariableRead-TestCase"); int variables = variablesinitvalue; TimeSpan variabletimespanTS = TimeSpan.Parse(variabletimespan); telemetry = new Telemetry(Program.VmName, Path, variables, adapter); telemetry.SetID("variable"); telemetry.InitTelemetryCollection("variable"); while (mRunning) { for (int i = 0; i < variableiterations; i++) { PrepareReadMultiple(variables, variabletimespanTS); var sw = System.Diagnostics.Stopwatch.StartNew(); ReadMultiple(variables, variabletimespanTS); sw.Stop(); double elap = sw.Elapsed.TotalMilliseconds; string logtext = "Variables: " + variables + " Duration: " + elap; System.Console.WriteLine(logtext); try { outputfile.WriteLine(variables + "\t" + elap); } catch (System.ObjectDisposedException) { } } telemetry.CollectVariableRunTelemetry(variables); variables += variableinc; if (variables > maxvariables) { break; } try { outputfile.WriteLine("New Variable count: " + variables + "\t"); } catch (System.ObjectDisposedException) { } } telemetry.CloseVMConnection(); } #endregion #region Client Test using (outputfile = new System.IO.StreamWriter(Path + "\\client_read_test.txt")) { outputfile.WriteLine("Database: " + Program.Database + "\t MaxClient: " + maxclients + "\t Iterations: " + clientiterations + "\t Timespan: " + clienttimespan + "\t Variables: " + clientvariables + "\t WriteFrequency: " + writefrequency); outputfile.WriteLine("Clients\tDuration(ms)"); //ClientRead-TestCase System.Console.WriteLine("Start ClientRead-TestCase"); int clients = clientsinitvalue; TimeSpan clienttimespanTS = TimeSpan.Parse(clienttimespan); Running = true; for (int i = 0; i < clients; i++) { System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ReadStaticC)) { IsBackground = false }; Params a = new Params(clientvariables, clienttimespanTS); t.Start(a); clientlist.Add(t); } System.Threading.Thread.Sleep(2000); PrepareReadMultiple(clientvariables, clienttimespanTS); telemetry = new Telemetry(Program.VmName, Path, clients, adapter); telemetry.SetID("client"); telemetry.InitTelemetryCollection("client"); while (mRunning) { for (int i = 0; i < clientiterations; i++) { var sw = System.Diagnostics.Stopwatch.StartNew(); ReadStatic(clientvariables, clienttimespanTS); sw.Stop(); double elap = sw.Elapsed.TotalMilliseconds; string logtext = "Clients: " + clients + " Duration: " + elap; System.Console.WriteLine(logtext); try { outputfile.WriteLine(clients + "\t" + elap); } catch (System.ObjectDisposedException) { } } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); telemetry.CollectVariableRunTelemetry(clients); clients += clientinc; if (clients > maxclients) { break; } System.Threading.ThreadPool.GetAvailableThreads(out int awt, out int acpt); System.Console.WriteLine("Available: " + awt + " IO: " + acpt); while (clientlist.Count <= clients) { System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ReadStaticC)) { IsBackground = false }; Params a = new Params(clientvariables, clienttimespanTS); t.Start(a); clientlist.Add(t); //System.Threading.Thread.Sleep(500); } System.Threading.ThreadPool.GetAvailableThreads(out int awt2, out int acpt2); System.Console.WriteLine("After increase Available: " + awt2 + " IO: " + acpt2); System.Threading.Thread.Sleep(2000); try { outputfile.WriteLine("New Client count: " + clients + "\t"); } catch (System.ObjectDisposedException) { } System.Threading.Thread.Sleep(5000); } System.Console.WriteLine("ClientList.Count: " + clientlist.Count); foreach (var th in clientlist) { if (!th.IsAlive) { System.Console.WriteLine("Client not alive"); } } Running = false; foreach (var t in clientlist) { t.Join(); } telemetry.CloseVMConnection(); } #endregion }
public void Run() { mRunning = true; int sleep = 1000 / frequency; using (outputfile = new System.IO.StreamWriter(Path + "\\write_test.txt")) { outputfile.WriteLine("Database: " + Program.Database + "\t Variables: " + variables + "\t Iterations: " + iterations + "\t WriteFrequency: " + frequency); outputfile.WriteLine("Insert duration\tFinal duration\tRead back\tSpeed"); //Write-TestCase System.Console.WriteLine("Start Write-TestCase"); telemetry = new Telemetry(Program.VmName, Path, variables, adapter); telemetry.InitTelemetryCollection("write"); var w_mock = new System.Diagnostics.Stopwatch(); var endinittime = System.DateTime.Now.Add(inititerations); while (endinittime.Subtract(System.DateTime.Now).TotalSeconds > 0) { if (!mRunning) { break; } var st = System.Diagnostics.Stopwatch.StartNew(); PrepareData(initvariables); Send(ref w_mock); st.Stop(); double elap = st.Elapsed.TotalSeconds; int wait = sleep - (int)(elap * 1000); if (wait > 0) { System.Threading.Thread.Sleep(wait); } } while (mRunning) { for (int j = 0; j < iterations; j++) { if (!mRunning) { break; } var st = System.Diagnostics.Stopwatch.StartNew(); if (frequency > 1) { for (int i = 1; i < frequency; i++) { var st0 = System.Diagnostics.Stopwatch.StartNew(); PrepareData(variables); Send(ref w_mock); double elap0 = st0.Elapsed.TotalSeconds; int wait0 = sleep - (int)(elap0 * 1000); if (wait0 > 0) { System.Threading.Thread.Sleep(wait0); } } } var check00 = st.Elapsed.TotalSeconds; PrepareData(variables); var check0 = st.Elapsed.TotalSeconds; Send(ref onevariable_watch); var check1 = st.Elapsed.TotalSeconds; while (true) { bool x = CheckInsert(); if (x) { break; } System.Threading.Thread.Sleep(100); } onevariable_watch.Stop(); st.Stop(); double elap = st.Elapsed.TotalSeconds; double d = check0 - check00; string logtext = "Insert duration: " + check1 + " Final duration: " + elap + " Read back: " + onevariable_watch.Elapsed.TotalSeconds + " PrepareData: " + d; System.Console.WriteLine(logtext); float speed = (float)(variables / elap); System.Console.WriteLine("Speed: " + speed); try { outputfile.WriteLine(check1 + "\t" + elap + "\t" + onevariable_watch.Elapsed.TotalSeconds + "\t" + speed); } catch (System.ObjectDisposedException) { } onevariable_watch.Reset(); int wait = 1000 - (int)(elap * 1000); if (wait > 0) { System.Threading.Thread.Sleep(wait); } } if (mRunning) { variables += increament; //Increase updated variable count telemetry.CollectVariableRunTelemetry(variables); if (variables >= stop_value) { mRunning = false; break; } try { outputfile.WriteLine("New Variable count: " + variables + "\t"); } catch (System.ObjectDisposedException) { } } } telemetry.CloseVMConnection(); } }