public void CompareBuildingSpeeds() { m_custTable= new DataTable("Customers"); // add columns m_custTable.Columns.Add( "id", typeof(int) ); m_custTable.Columns.Add( "name", typeof(string) ); m_custTable.Columns.Add( "address", typeof(string) ); m_custTable.Columns.Add( "min", typeof(int) ); m_custTable.Columns["min"].DefaultValue = 0; m_custTable.Columns.Add( "max", typeof(int) ); m_custTable.Columns.Add( "Client name", typeof(string) ); m_custTable.Columns.Add( "Type of software", typeof(string) ); //m_custTable.Columns[ "id" ].Unique = true; //m_custTable.PrimaryKey = new DataColumn[] { m_custTable.Columns["id"] }; //m_custTable.ColumnChanging += new DataColumnChangeEventHandler(custTable_ColumnChanging); //m_custTable.RowChanging += new DataRowChangeEventHandler(custTable_RowChanging); int maxRows = 1000000; using (IPerformanceCounter counter = new PerformanceCounter()) { AddRows(0, maxRows); Console.WriteLine(string.Format( "Added {0} number of rows to datatable in {1} milisec", maxRows, counter.GetMilisec())); } List<object[]> objects = new List<object[]>(); using (IPerformanceCounter counter = new PerformanceCounter()) { for( int id = 0; id <= maxRows; id++ ) { int valMin = rnd.Next(Int32.MinValue, Int32.MaxValue); objects.Add( new object[] { id, string.Format("customer{0}", id), string.Format("address{0}", id ), valMin, valMin + rnd.Next(1, 1000), customerNames[rnd.Next(0, customerNames.Length)], typesOfSoftware[rnd.Next(0, typesOfSoftware.Length)] } ); } Console.WriteLine(string.Format( "Added {0} number of rows to list<object[]> in {1} milisec", maxRows, counter.GetMilisec())); } }
public void GetRowsIndex_Performance() { // this test, sadly, tests nothing // remove it RangeRegion region = new RangeRegion(new Range(0, 0, 10000, 5000)); using (IPerformanceCounter counter = new PerformanceCounter()) { region.GetRowsIndex(); Console.WriteLine(string.Format( "Test executed in {0} ms", counter.GetMilisec())); } }
public List<Range> GetRanges(RangeCreator ranges) { List<Range> results = new List<Range>(); for (var col = 0; col < ranges.ColCount; col++) for (var row = 0; row < ranges.RowCount; row++) { Range? index; IPerformanceCounter counter = null; using (counter = new PerformanceCounter()) { index = ranges.SpannedRangesList.GetFirstIntersectedRange(new Position(row, col)); } TotalQueries ++; TotalTimeSpent += counter.GetMilisec(); if (index != null) results.Add(index.Value); } AverageTimeSpent = TotalTimeSpent / TotalQueries; return results; }
public List<Range> GetRanges(QuadTree tree) { List<Range> results = new List<Range>(); for (var col = 0; col < tree.Bounds.ColumnsCount; col++) for (var row = 0; row < tree.Bounds.RowsCount; row++) { List<Range> ranges = null; IPerformanceCounter counter = null; using (counter = new PerformanceCounter()) { ranges = tree.Query(new Position(row, col)); } TotalQueries ++; TotalTimeSpent += counter.GetMilisec(); results.AddRange(ranges); } AverageTimeSpent = TotalTimeSpent / TotalQueries; return results; }
public void SpannedCellCreation_Performance() { // originaly this test run in ~11900 ms // after implementing this takes 1350ms :) var grid = new Grid(); var count = 10000; var columns = 500; grid.Redim(count, columns); using (var counter = new PerformanceCounter()) { for (int i = 0; i < count; i++) { grid[i, 0] = new Cell(); grid[i, 0].SetSpan(50, 500); i+=50; } Console.WriteLine("Test finished in {0} ms", counter.GetMilisec()); } }
private void btLoad_Click(object sender, System.EventArgs e) { using (var counter = new PerformanceCounter()) { grid.Redim(0, 0); //Visual properties shared between all the cells SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text)); if (chkAddHeaders.Checked && grid.RowsCount > 0 && grid.ColumnsCount > 0) { grid.FixedRows = 1; grid.FixedColumns = 1; for (int r = grid.FixedRows; r < grid.RowsCount; r++) grid[r, 0] = new SourceGrid.Cells.RowHeader(r); for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(c); header.AutomaticSortEnabled = false; grid[0, c] = header; } grid[0, 0] = new SourceGrid.Cells.Header(); } else { grid.FixedRows = 0; grid.FixedColumns = 0; } for (int r = grid.FixedRows; r < grid.RowsCount; r++) for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString()); grid[r, c].Editor = editor; grid[r, c].View = view; var span = 3; if (chkAddColspan.Checked && (c + span < grid.ColumnsCount)) { if (r % 2 == 0) { grid[r, c].ColumnSpan = span; c += span; } } } grid.Selection.Focus(new SourceGrid.Position(0, 0), true); this.toolStripStatusLabelBuildTime.Text = string.Format( "Rows added in {0} ms", counter.GetMilisec()); } }