public void ReportWritesProgress(int threadId, int sent, int prepareTimeouts, int commitTimeouts, int forwardTimeouts, int wrongExpctdVersions, int streamsDeleted, int fails, int requests) { var sentP = ToPercent(sent, requests); var failsP = ToPercent(fails, sent); var table = new ConsoleTable("WRITER ID", "Completed %", "Completed/Total", "Failed %", "Failed/Sent", "Prepare Timeouts", "Commit Timeouts", "Forward Timeouts", "Wrong Versions", "Stream Deleted"); table.AppendRow(threadId.ToString(), string.Format("{0:0.0}%", sentP), string.Format("{0}/{1}", sent, requests), string.Format("{0:0.0}%", failsP), string.Format("{0}/{1}", fails, sent), prepareTimeouts.ToString(), commitTimeouts.ToString(), forwardTimeouts.ToString(), wrongExpctdVersions.ToString(), streamsDeleted.ToString()); if (failsP > 50d) _log.Fatal(table.CreateIndentedTable()); else _log.Info(table.CreateIndentedTable()); }
public void ReportWritesProgress(int threadId, int sent, int prepareTimeouts, int commitTimeouts, int forwardTimeouts, int wrongExpctdVersions, int streamsDeleted, int fails, int requests) { var sentP = ToPercent(sent, requests); var failsP = ToPercent(fails, sent); var table = new ConsoleTable("WRITER ID", "Completed %", "Completed/Total", "Failed %", "Failed/Sent", "Prepare Timeouts", "Commit Timeouts", "Forward Timeouts", "Wrong Versions", "Stream Deleted"); table.AppendRow(threadId.ToString(), string.Format("{0:0.0}%", sentP), string.Format("{0}/{1}", sent, requests), string.Format("{0:0.0}%", failsP), string.Format("{0}/{1}", fails, sent), prepareTimeouts.ToString(), commitTimeouts.ToString(), forwardTimeouts.ToString(), wrongExpctdVersions.ToString(), streamsDeleted.ToString()); if (failsP > 50d) { _log.Fatal(table.CreateIndentedTable()); } else { _log.Info(table.CreateIndentedTable()); } }
public void Write(AssemblyStatistic[] statistics, TimeSpan time) { var outputDirectory = !this.OutputDirectory.IsNullOrEmpty() ? this.OutputDirectory : statistics[0].AssemblyData.File.DirectoryName; foreach (var statistic in statistics) { this.WriteStatistic(outputDirectory, statistic); } string summaryFile = Path.Combine(outputDirectory, "diet.summary"); using (var writer = new StreamWriter(summaryFile)) { writer.WriteLine("Total assemblies: {0}.", statistics.Length); writer.WriteLine(); var table = new ConsoleTable(); table.SetHeaders(new[] { "Assembly", "Unused", "Ignored*" }); this.AddPartitionSummary(table, "Roots", statistics.Where(s => s.InspectedAsRoot)); table.AppendRow(new[] { string.Empty, string.Empty, string.Empty }); this.AddPartitionSummary(table, "Other", statistics.Where(s => !s.InspectedAsRoot)); writer.Write(table.ToString()); writer.WriteLine(" * ignored code was probably code-generated"); writer.WriteLine(); writer.WriteLine("Analysed in {0}.", time); } }
private bool Verify(CommandProcessorContext context, int writers, int readers, int events) { var readStatuses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToArray(); var readNotifications = Enumerable.Range(0, readers).Select(x => new ManualResetEventSlim(false)).ToArray(); var writeStatuses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToArray(); var writeNotifications = Enumerable.Range(0, writers).Select(x => new ManualResetEventSlim(false)).ToArray(); for (int i = 0; i < readers; i++) { var i1 = i; var thread = new Thread(() => Read(readStatuses[i1], i1, context, readNotifications[i1])); thread.IsBackground = true; thread.Start(); } for (int i = 0; i < writers; i++) { var i1 = i; var thread = new Thread(() => Write(writeStatuses[i1], i1, context, events / writers, writeNotifications[i1])); thread.IsBackground = true; thread.Start(); } foreach (var writeNotification in writeNotifications) { writeNotification.Wait(); } _stopReading = true; foreach (var readNotification in readNotifications) { readNotification.Wait(); } context.Log.Info("dvub finished execution : "); var writersTable = new ConsoleTable("WRITER ID", "Status"); foreach (var ws in writeStatuses) { writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail"); } var readersTable = new ConsoleTable("READER ID", "Status"); foreach (var rs in readStatuses) { readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail"); } context.Log.Info(writersTable.CreateIndentedTable()); context.Log.Info(readersTable.CreateIndentedTable()); var success = writeStatuses.All(s => s.Success) && readStatuses.All(s => s.Success); if (success) context.Success(); else context.Fail(); return success; }
public void ReportReadsProgress(int threadId, int successes, int fails) { var all = successes + fails; var table = new ConsoleTable("READER ID", "Fails", "Total Random Reads"); table.AppendRow(threadId.ToString(), fails.ToString(), all.ToString()); if (fails != 0) _log.Fatal(table.CreateIndentedTable()); else _log.Info(table.CreateIndentedTable()); }
private void AddPartitionSummary(ConsoleTable table, string title, IEnumerable <AssemblyStatistic> statistics) { table.AppendRow(new[] { title, string.Empty, string.Empty }); var rows = from statistic in statistics let name = statistic.AssemblyData.Name orderby name select new[] { " " + name, FormatRatio(statistic.UnusedMemberRatio), FormatRatio(statistic.IgnoredMemberRatio) }; rows.ForEach(table.AppendRow); }
public void NotifyEventCommitted(VerificationEvent @event) { _eventsForVerification.Enqueue(@event); var com = Interlocked.Increment(ref _totalWritten); if (com % NotificationStep == 0) { var table = new ConsoleTable("WORKER", "COMMITTED"); table.AppendRow("WRITER", com.ToString()); Log.Info(table.CreateIndentedTable()); } }
public void ReportReadsProgress(int threadId, int successes, int fails) { var all = successes + fails; var table = new ConsoleTable("READER ID", "Fails", "Total Random Reads"); table.AppendRow(threadId.ToString(), fails.ToString(), all.ToString()); if (fails != 0) { _log.Fatal(table.CreateIndentedTable()); } else { _log.Info(table.CreateIndentedTable()); } }
public void NotifyEventVerified(VerificationEvent @event) { var ver = Interlocked.Increment(ref _totalVerified); if (ver % NotificationStep == 0) { var table = new ConsoleTable("WORKER", "VERIFIED"); table.AppendRow("VERIFIER", ver.ToString()); Log.Info(table.CreateIndentedTable()); } var committed = _totalWritten; if (committed == _totalEvents) { _doneEvent.Set(); } }
private bool Verify(CommandProcessorContext context, int writers, int readers, int events) { var readStatusses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToList(); var readNotifications = new List <AutoResetEvent>(); for (int i = 0; i < readers; i++) { readNotifications.Add(new AutoResetEvent(false)); } for (int i = 0; i < readers; i++) { var i1 = i; new Thread(() => Read(readStatusses[i1], i1, context, readNotifications[i1])) { IsBackground = true }.Start(); } var writeStatusses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToList(); var writeNotifications = new List <AutoResetEvent>(); for (int i = 0; i < writers; i++) { writeNotifications.Add(new AutoResetEvent(false)); } for (int i = 0; i < writers; i++) { var i1 = i; new Thread(() => Write(writeStatusses[i1], i1, context, events / writers, writeNotifications[i1])) { IsBackground = true }.Start(); } writeNotifications.ForEach(w => w.WaitOne()); _stopReading = true; readNotifications.ForEach(r => r.WaitOne()); context.Log.Info("dvub finished execution : "); var writersTable = new ConsoleTable("WRITER ID", "Status"); writeStatusses.ForEach(ws => { writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail"); }); var readersTable = new ConsoleTable("READER ID", "Status"); readStatusses.ForEach(rs => { readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail"); }); context.Log.Info(writersTable.CreateIndentedTable()); context.Log.Info(readersTable.CreateIndentedTable()); var success = writeStatusses.All(s => s.Success) && readStatusses.All(s => s.Success); if (success) { context.Success(); } else { context.Fail(); } return(success); }
private bool Verify(CommandProcessorContext context, int writers, int readers, int events) { var readStatuses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToArray(); var readNotifications = Enumerable.Range(0, readers).Select(x => new ManualResetEventSlim(false)).ToArray(); var writeStatuses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToArray(); var writeNotifications = Enumerable.Range(0, writers).Select(x => new ManualResetEventSlim(false)).ToArray(); for (int i = 0; i < readers; i++) { var i1 = i; var thread = new Thread(() => Read(readStatuses[i1], i1, context, readNotifications[i1])); thread.IsBackground = true; thread.Start(); } for (int i = 0; i < writers; i++) { var i1 = i; var thread = new Thread(() => Write(writeStatuses[i1], i1, context, events / writers, writeNotifications[i1])); thread.IsBackground = true; thread.Start(); } foreach (var writeNotification in writeNotifications) { writeNotification.Wait(); } _stopReading = true; foreach (var readNotification in readNotifications) { readNotification.Wait(); } context.Log.Info("dvub finished execution : "); var writersTable = new ConsoleTable("WRITER ID", "Status"); foreach (var ws in writeStatuses) { writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail"); } var readersTable = new ConsoleTable("READER ID", "Status"); foreach (var rs in readStatuses) { readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail"); } context.Log.Info(writersTable.CreateIndentedTable()); context.Log.Info(readersTable.CreateIndentedTable()); var success = writeStatuses.All(s => s.Success) && readStatuses.All(s => s.Success); if (success) context.Success(); else context.Fail(); return success; }
private bool Verify(CommandProcessorContext context, int writers, int readers, int events) { var readStatusses = Enumerable.Range(0, readers).Select(x => new Status(context.Log)).ToList(); var readNotifications = new List<AutoResetEvent>(); for (int i = 0; i < readers; i++) readNotifications.Add(new AutoResetEvent(false)); for (int i = 0; i < readers; i++) { var i1 = i; new Thread(() => Read(readStatusses[i1], i1, context, readNotifications[i1])) { IsBackground = true }.Start(); } var writeStatusses = Enumerable.Range(0, writers).Select(x => new Status(context.Log)).ToList(); var writeNotifications = new List<AutoResetEvent>(); for (int i = 0; i < writers; i++) writeNotifications.Add(new AutoResetEvent(false)); for (int i = 0; i < writers; i++) { var i1 = i; new Thread(() => Write(writeStatusses[i1], i1, context, events / writers, writeNotifications[i1])) { IsBackground = true }.Start(); } writeNotifications.ForEach(w => w.WaitOne()); _stopReading = true; readNotifications.ForEach(r => r.WaitOne()); context.Log.Info("dvub finished execution : "); var writersTable = new ConsoleTable("WRITER ID", "Status"); writeStatusses.ForEach(ws => { writersTable.AppendRow(ws.ThreadId.ToString(), ws.Success ? "Success" : "Fail"); }); var readersTable = new ConsoleTable("READER ID", "Status"); readStatusses.ForEach(rs => { readersTable.AppendRow(rs.ThreadId.ToString(), rs.Success ? "Success" : "Fail"); }); context.Log.Info(writersTable.CreateIndentedTable()); context.Log.Info(readersTable.CreateIndentedTable()); var success = writeStatusses.All(s => s.Success) && readStatusses.All(s => s.Success); if(success) context.Success(); else context.Fail(); return success; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { SQLiteClient db; SQLiteResultSet results; Console.WriteLine("Basic test app for SQLite.NET. Enter a single line sql query and it will be run against the database.\r\n"); Console.WriteLine("Opening database 'test.db'...\r\n"); try { // Open database db = new SQLiteClient("test.db"); } catch (SQLiteException e) { Console.WriteLine("Fatal error: {0}", e.Message); Console.ReadLine(); return; } Console.WriteLine("Available tables:"); ArrayList tables = db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'"); foreach (string tableName in tables) { Console.WriteLine("\t" + tableName); } // Main loop while (true) { Console.Write("SQL> "); string input = Console.ReadLine(); if (input == null || input.Trim() == "") { continue; } if (input == ".quit") { return; } try { results = db.Execute(input); ConsoleTable table = new ConsoleTable(); table.SetHeaders(results.ColumnNames); // Loop through the results and display them foreach (ArrayList arr in results.Rows) { table.AppendRow(arr); } while (results.IsMoreData) { Hashtable foo = results.GetRowHash(); foo.GetType(); } Console.WriteLine(table.ToString()); } catch (SQLiteException e) { Console.WriteLine(e.Message); } } }
public void NotifyEventVerified(VerificationEvent @event) { var ver = Interlocked.Increment(ref _totalVerified); if (ver % NotificationStep == 0) { var table = new ConsoleTable("WORKER", "VERIFIED"); table.AppendRow("VERIFIER", ver.ToString()); Log.Info(table.CreateIndentedTable()); } var committed = _totalWritten; if (committed == _totalEvents) _doneEvent.Set(); }
public void NotifyEventCommitted(VerificationEvent @event) { _eventsForVerification.Enqueue(@event); var com = Interlocked.Increment(ref _totalWritten); if (com % NotificationStep == 0) { var table = new ConsoleTable("WORKER", "COMMITTED"); table.AppendRow("WRITER", com.ToString()); Log.Info(table.CreateIndentedTable()); } }